]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Ensure array lengthgs are Int literals 2021-04-upstream-confirm
authorMatt Corallo <git@bluematt.me>
Mon, 26 Apr 2021 16:59:43 +0000 (16:59 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 26 Apr 2021 16:59:43 +0000 (16:59 +0000)
This fixes a bug where an array will be converted to
[u8; StringLiteral] which results in us deciding we don't know how
to map it.

Fixes: dec732cefbdd97585b7de7fd4a9521f44f1580dd
c-bindings-gen/src/types.rs

index c230770d144a2ccc1808aabdac2946b48fe181c3..b0a410e208f01e9ff6f941234df862bbb4645c90 100644 (file)
@@ -1458,7 +1458,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                split.next().unwrap();
                                let tail_str = split.next().unwrap();
                                assert!(split.next().is_none());
-                               let len = &tail_str[..tail_str.len() - 1];
+                               let len = usize::from_str_radix(&tail_str[..tail_str.len() - 1], 10).unwrap();
                                Some(parse_quote!([u8; #len]))
                        } else { None }
                } else { None }