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
1 changed files with 3 additions and 2 deletions

View File

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