Skip to content

Commit

Permalink
Add NULL check at shlr/sdb/src/json/api.c (radareorg#7859)
Browse files Browse the repository at this point in the history
  • Loading branch information
j123123 authored and radare committed Jul 5, 2017
1 parent 5df1641 commit f3f71b1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion shlr/sdb/src/json/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ char *api_json_set (const char *s, const char *k, const char *v) {
int idx, len[3];
char *str = NULL;
Rangstr rs = json_get (s, k);
if (!rs.p) return NULL;
if (!rs.p) {
return NULL;
}
#define WLEN(x) (int)(size_t)(end[x]-beg[x])

beg[0] = s;
Expand All @@ -35,6 +37,9 @@ char *api_json_set (const char *s, const char *k, const char *v) {
len[2] = WLEN (2);

str = malloc (len[0]+len[1]+len[2]+1);
if (!str) {
return NULL;
}
idx = len[0];
memcpy (str, beg[0], idx);
memcpy (str+idx, beg[1], len[1]);
Expand Down

0 comments on commit f3f71b1

Please sign in to comment.