From 2f4ba73c77a6ec80fcd1e37a58d55b6793c9a261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rge=20Dijkstra?= Date: Mon, 22 Jan 2018 23:27:46 +0100 Subject: [PATCH] Allocate hex buffer on heap since it can be very large. --- common/json.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/json.c b/common/json.c index 0934b2951..371b43ae7 100644 --- a/common/json.c +++ b/common/json.c @@ -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, 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); + tal_free(hex); } void json_add_object(struct json_result *result, ...)