From fe6c7f8f805de0488a2a29c82844b73017a9f9bd Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Wed, 28 Aug 2019 16:29:16 -0500 Subject: [PATCH] gossip queries: patch up valgrind errors in tests These were giving me valgrind errors locally; fixed now. --- gossipd/gossipd.c | 2 ++ gossipd/test/run-extended-info.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) 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; }