Browse Source

initialize null terminator of new printbuf

It's possible (e.g. by using json_object_from_file() on an empty file)
to get json-c to try to use a printbuf that has never had anything
written to it. Before this change, it could access a string that
should be length zero, but was never initialized, and could
theoretically have an unexpected string.
tags/json-c-0.13-20171207
Pierce Lopez 9 years ago
parent
commit
868b20ce4e
1 changed files with 1 additions and 0 deletions
  1. +1
    -0
      printbuf.c

+ 1
- 0
printbuf.c View File

@@ -42,6 +42,7 @@ struct printbuf* printbuf_new(void)
free(p); free(p);
return NULL; return NULL;
} }
p->buf[0]= '\0';
return p; return p;
} }




Loading…
Cancel
Save