mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-07 16:14:26 +01:00
utils: make tal_arr_expand safer.
Christian and I both unwittingly used it in form: *tal_arr_expand(&x) = tal(x, ...) Since '=' isn't a sequence point, the compiler can (and does!) cache the value of x, handing it to tal *after* tal_arr_expand() moves it due to tal_resize(). The new version is somewhat less convenient to use, but doesn't have this problem, since the assignment is always evaluated after the resize. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
a5ed98a2ea
commit
26dda57cc0
@@ -16,7 +16,7 @@ struct msg_queue *msg_queue_new(const tal_t *ctx)
|
||||
|
||||
static void do_enqueue(struct msg_queue *q, const u8 *add TAKES)
|
||||
{
|
||||
*tal_arr_expand(&q->q) = tal_dup_arr(q, u8, add, tal_count(add), 0);
|
||||
tal_arr_expand(&q->q, tal_dup_arr(q, u8, add, tal_count(add), 0));
|
||||
|
||||
/* In case someone is waiting */
|
||||
io_wake(q);
|
||||
|
||||
Reference in New Issue
Block a user