Skip to content

Commit

Permalink
json: fix oom when adding a long string
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyrussell committed Mar 2, 2021
1 parent d753ee2 commit 8af5764
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions common/json_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 8af5764

Please sign in to comment.