gossipd: fix longstanding logic error in gossip_generation.

`hc` is never NULL, since it's `hc = &chan->half[direction];`;
we really meant "is it initialized", and valgrind under CI finally
caught it:

```
==69243== Conditional jump or move depends on uninitialised value(s)
==69243==    at 0x11C595: handle_local_channel_update (gossip_generation.c:758)
==69243==    by 0x115254: recv_req (gossipd.c:986)
==69243==    by 0x128F8D: handle_read (daemon_conn.c:31)
==69243==    by 0x16BEE1: next_plan (io.c:59)
==69243==    by 0x16CAE9: do_plan (io.c:407)
==69243==    by 0x16CB2B: io_ready (io.c:417)
==69243==    by 0x16EE1E: io_loop (poll.c:453)
==69243==    by 0x1154DA: main (gossipd.c:1089)
==69243==
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-01-30 14:07:30 +10:30
parent e8d2176e6b
commit d370aac020
1 changed files with 1 additions and 1 deletions

View File

@ -751,7 +751,7 @@ void handle_local_channel_update(struct daemon *daemon, const u8 *msg)
return;
/* Too early? Defer (don't worry if it's unannounced). */
if (hc && is_chan_public(chan)) {
if (is_halfchan_defined(hc) && is_chan_public(chan)) {
u32 now = time_now().ts.tv_sec;
u32 next_time = hc->bcast.timestamp
+ GOSSIP_MIN_INTERVAL(daemon->rstate->dev_fast_gossip);