json: fix oom when adding a long string

This commit is contained in:
Rusty Russell 2021-02-26 10:11:28 +01:00
parent d753ee27a2
commit 8af5764a9c

View File

@ -194,8 +194,9 @@ void json_add_jsonstr(struct json_stream *js,
size_t len = strlen(jsonstr); size_t len = strlen(jsonstr);
p = json_member_direct(js, fieldname, len); p = json_member_direct(js, fieldname, len);
/* Could be OOM! */
memcpy(p, jsonstr, len); if (p)
memcpy(p, jsonstr, len);
} }
/* This is where we read the json_stream and write it to conn */ /* This is where we read the json_stream and write it to conn */