common/gossmap: fix gossmap_node_get_announce() on unannounced nodes.

We would return junk before.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-10-20 14:28:06 +10:30
parent bb9ad57a03
commit 52c465fef0

View file

@ -823,8 +823,14 @@ u8 *gossmap_node_get_announce(const tal_t *ctx,
const struct gossmap *map,
const struct gossmap_node *n)
{
u16 len = map_be16(map, n->nann_off);
u8 *msg = tal_arr(ctx, u8, len);
u16 len;
u8 *msg;
if (n->nann_off == 0)
return NULL;
len = map_be16(map, n->nann_off);
msg = tal_arr(ctx, u8, len);
map_copy(map, n->nann_off, msg, len);
return msg;