From c100de6d938cd9441e4696bab6ad4d4ae2cdbf71 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj jxPCSnmZ Date: Mon, 22 Jun 2020 12:15:42 +0800 Subject: [PATCH] common/utils.c: Correctly handle NULL `take`n pointer in `tal_dup_talarr`. Fixes: #3757 Reported-by: @sumBTC Changelog-None --- common/utils.c | 7 +++++-- tests/test_pay.py | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/utils.c b/common/utils.c index 62432f600..37c4457fc 100644 --- a/common/utils.c +++ b/common/utils.c @@ -142,9 +142,12 @@ void tal_arr_remove_(void *p, size_t elemsize, size_t n) tal_resize((char **)p, len - elemsize); } -void *tal_dup_talarr_(const tal_t *ctx, const tal_t *src, const char *label) +void *tal_dup_talarr_(const tal_t *ctx, const tal_t *src TAKES, const char *label) { - if (!src) + if (!src) { + /* Correctly handle TAKES on a NULL `src`. */ + (void) taken(src); return NULL; + } return tal_dup_(ctx, src, 1, tal_bytelen(src), 0, label); } diff --git a/tests/test_pay.py b/tests/test_pay.py index 66dada0a9..1053ce6f3 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -3019,7 +3019,6 @@ def test_keysend(node_factory): assert(inv['msatoshi_received'] >= amt) -@pytest.mark.xfail(strict=True) def test_invalid_onion_channel_update(node_factory): ''' Some onion failures "should" send a `channel_update`.