mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
fromwire: return NULL if array empty
libwally's API requires us to pass in NULL pointers if the array size is zero, so we update our array from wire-er to comply with this requirement [ Added fix to avoid tal_resize() of NULL -- RR ]
This commit is contained in:
@@ -195,8 +195,9 @@ u8 *get_agreed_channelfeatures(const tal_t *ctx,
|
|||||||
max_len = (i / 8) + 1;
|
max_len = (i / 8) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Trim to length */
|
/* Trim to length (unless it's already NULL). */
|
||||||
tal_resize(&f, max_len);
|
if (f)
|
||||||
|
tal_resize(&f, max_len);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,9 @@ u8 *fromwire_tal_arrn(const tal_t *ctx,
|
|||||||
const u8 **cursor, size_t *max, size_t num)
|
const u8 **cursor, size_t *max, size_t num)
|
||||||
{
|
{
|
||||||
u8 *arr;
|
u8 *arr;
|
||||||
|
if (num == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (num > *max)
|
if (num > *max)
|
||||||
return fromwire_fail(cursor, max);
|
return fromwire_fail(cursor, max);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user