devtools/decodemsg: don't crash if we have multiple tlv options.

We call tal_count(msg) after we've moved msg, and that causes an abort.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-04-07 16:33:04 +09:30 committed by neil saitug
parent d2165ff4d8
commit 11c21f97a6

View File

@ -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}));
}