gossip queries: patch up valgrind errors in tests

These were giving me valgrind errors locally; fixed now.
This commit is contained in:
lisa neigut 2019-08-28 16:29:16 -05:00 committed by Rusty Russell
parent a35677fa0f
commit fe6c7f8f80
2 changed files with 8 additions and 3 deletions

View File

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

View File

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