mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
Allocate hex buffer on heap since it can be very large.
This commit is contained in:
committed by
Christian Decker
parent
5631054152
commit
2f4ba73c77
@@ -503,10 +503,11 @@ void json_add_null(struct json_result *result, const char *fieldname)
|
|||||||
void json_add_hex(struct json_result *result, const char *fieldname,
|
void json_add_hex(struct json_result *result, const char *fieldname,
|
||||||
const void *data, size_t len)
|
const void *data, size_t len)
|
||||||
{
|
{
|
||||||
char hex[hex_str_size(len)];
|
char *hex = tal_arr(NULL, char, hex_str_size(len));
|
||||||
|
|
||||||
hex_encode(data, len, hex, sizeof(hex));
|
hex_encode(data, len, hex, hex_str_size(len));
|
||||||
json_add_string(result, fieldname, hex);
|
json_add_string(result, fieldname, hex);
|
||||||
|
tal_free(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void json_add_object(struct json_result *result, ...)
|
void json_add_object(struct json_result *result, ...)
|
||||||
|
|||||||
Reference in New Issue
Block a user