Allocate hex buffer on heap since it can be very large.

This commit is contained in:
Björge Dijkstra 2018-01-22 23:27:46 +01:00 committed by Christian Decker
parent 5631054152
commit 2f4ba73c77

View File

@ -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, ...)