diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index d2db14193..24c754368 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -360,6 +360,8 @@ static bool encoding_end_zlib(u8 **encoded, size_t off) /* Successful: copy over and trim */ tal_resize(encoded, off + tal_count(z)); memcpy(*encoded + off, z, tal_count(z)); + + tal_free(z); return true; } diff --git a/gossipd/test/run-extended-info.c b/gossipd/test/run-extended-info.c index bdc974cd1..aa20cecb0 100644 --- a/gossipd/test/run-extended-info.c +++ b/gossipd/test/run-extended-info.c @@ -602,6 +602,7 @@ static u8 *test_query_channel_range(const char *test_vector, const jsmntok_t *ob } msg = towire_query_channel_range(NULL, &chain_hash, firstBlockNum, numberOfBlocks, tlvs); + tal_free(tlvs); return msg; } @@ -613,15 +614,17 @@ static u8 *test_reply_channel_range(const char *test_vector, const jsmntok_t *ob size_t i; u8 *msg; u8 *encoded_scids; + + u8 *ctx = tal(NULL, u8); struct tlv_reply_channel_range_tlvs *tlvs - = tlv_reply_channel_range_tlvs_new(NULL); + = tlv_reply_channel_range_tlvs_new(ctx); get_chainhash(test_vector, obj, &chain_hash); assert(json_to_number(test_vector, json_get_member(test_vector, obj, "firstBlockNum"), &firstBlockNum)); assert(json_to_number(test_vector, json_get_member(test_vector, obj, "numberOfBlocks"), &numberOfBlocks)); assert(json_to_number(test_vector, json_get_member(test_vector, obj, "complete"), &complete)); - encoded_scids = get_scid_array(NULL, test_vector, obj); + encoded_scids = get_scid_array(ctx, test_vector, obj); opt = json_get_member(test_vector, obj, "timestamps"); if (opt) { @@ -686,7 +689,7 @@ static u8 *test_reply_channel_range(const char *test_vector, const jsmntok_t *ob msg = towire_reply_channel_range( NULL, &chain_hash, firstBlockNum, numberOfBlocks, complete, encoded_scids, tlvs); - tal_free(tlvs); + tal_free(ctx); return msg; }