diff options
Diffstat (limited to 'trace-input.c')
-rw-r--r-- | trace-input.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/trace-input.c b/trace-input.c index c55e94f..db48c91 100644 --- a/trace-input.c +++ b/trace-input.c | |||
@@ -139,7 +139,7 @@ static char *read_string(struct tracecmd_input *handle) | |||
139 | str[size] = 0; | 139 | str[size] = 0; |
140 | } else { | 140 | } else { |
141 | size = i + 1; | 141 | size = i + 1; |
142 | str = malloc(i); | 142 | str = malloc(size); |
143 | if (!str) | 143 | if (!str) |
144 | return NULL; | 144 | return NULL; |
145 | memcpy(str, buf, i); | 145 | memcpy(str, buf, i); |
@@ -369,13 +369,14 @@ static int read_proc_kallsyms(struct tracecmd_input *handle) | |||
369 | if (size < 0) | 369 | if (size < 0) |
370 | return -1; | 370 | return -1; |
371 | 371 | ||
372 | buf = malloc(size); | 372 | buf = malloc(size+1); |
373 | if (!buf) | 373 | if (!buf) |
374 | return -1; | 374 | return -1; |
375 | if (do_read_check(handle, buf, size)){ | 375 | if (do_read_check(handle, buf, size)){ |
376 | free(buf); | 376 | free(buf); |
377 | return -1; | 377 | return -1; |
378 | } | 378 | } |
379 | buf[size] = 0; | ||
379 | 380 | ||
380 | parse_proc_kallsyms(pevent, buf, size); | 381 | parse_proc_kallsyms(pevent, buf, size); |
381 | 382 | ||
@@ -1334,13 +1335,14 @@ int tracecmd_init_data(struct tracecmd_input *handle) | |||
1334 | size = read8(handle); | 1335 | size = read8(handle); |
1335 | if (size < 0) | 1336 | if (size < 0) |
1336 | return -1; | 1337 | return -1; |
1337 | cmdlines = malloc(size); | 1338 | cmdlines = malloc(size + 1); |
1338 | if (!cmdlines) | 1339 | if (!cmdlines) |
1339 | return -1; | 1340 | return -1; |
1340 | if (do_read_check(handle, cmdlines, size)) { | 1341 | if (do_read_check(handle, cmdlines, size)) { |
1341 | free(cmdlines); | 1342 | free(cmdlines); |
1342 | return -1; | 1343 | return -1; |
1343 | } | 1344 | } |
1345 | cmdlines[size] = 0; | ||
1344 | parse_cmdlines(pevent, cmdlines, size); | 1346 | parse_cmdlines(pevent, cmdlines, size); |
1345 | free(cmdlines); | 1347 | free(cmdlines); |
1346 | 1348 | ||