Skip to content

Commit

Permalink
devtools/decodemsg: don't crash if we have multiple tlv options.
Browse files Browse the repository at this point in the history
We call tal_count(msg) after we've moved msg, and that causes an abort.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell authored and niftynei committed Apr 7, 2020
1 parent d2165ff commit 11c21f9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tools/gen/print_impl_template
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ ${print_fieldset(msg.fields.values(), False, '&cursor', '&plen')}

void print${options.enum_name}_tlv_message(const char *tlv_name, const u8 *msg) {
% if bool(tlvs):
size_t plen;
size_t plen = tal_count(msg);
% for tlv_name in tlvs:
plen = tal_count(msg);
if (strcmp(tlv_name, "${tlv_name}") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_${tlv_name}, ARRAY_SIZE(print_tlvs_${tlv_name}));
}
Expand Down

0 comments on commit 11c21f9

Please sign in to comment.