summaryrefslogtreecommitdiffstats
path: root/src/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/json.c')
-rw-r--r--src/json.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/json.c b/src/json.c
index 4fcfcf5..aae6f5d 100644
--- a/src/json.c
+++ b/src/json.c
@@ -24,8 +24,9 @@ char * dc_json (struct dc_json * j, const char * in, int ln) { /* detects start/
ln = strlen(in);
i = bufstrlen;
if (bufstrlen + ln > j->bufcap)
- j->buf = realloc(j->buf, (j->bufcap=(bufstrlen+ln)*DC_REALLOC_K)*sizeof(char));
- strcpy(j->buf+bufstrlen, in);
+ j->buf = realloc(j->buf, (j->bufcap=(bufstrlen+ln+2)*DC_REALLOC_K)*sizeof(char));
+ strncpy(j->buf+bufstrlen, in, ln);
+ j->buf[bufstrlen+ln] = '\0';
bufstrlen += ln;
while (i < bufstrlen) {
if (j->instr) {
@@ -40,9 +41,9 @@ char * dc_json (struct dc_json * j, const char * in, int ln) { /* detects start/
}
if (!escaped) {
j->instr = 0;
- fprintf(stderr, "dc_json: j->instr = 0\n");
- } else
- fprintf(stderr, "dc_json: escaped\n");
+ /* fprintf(stderr, "dc_json: j->instr = 0\n"); */
+ } /* else
+ fprintf(stderr, "dc_json: escaped\n"); */
}
goto next;
}
@@ -54,7 +55,7 @@ char * dc_json (struct dc_json * j, const char * in, int ln) { /* detects start/
break;
case '"':
j->instr++;
- fprintf(stderr, "dc_json: j->instr++\n");
+ /* fprintf(stderr, "dc_json: j->instr++\n"); */
break;
case '}':
case ']':