From: HÃ¥vard Espeland Date: Tue, 4 May 2010 17:44:39 +0000 (+0200) Subject: Output: Fix invalid pointer dereferencing in vcd and gnuplot. X-Git-Tag: libsigrok-0.1.0~525 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e273a9040e10c1297c758fe35eb522bd5470e708;p=libsigrok.git Output: Fix invalid pointer dereferencing in vcd and gnuplot. --- diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index 6e6edd4c..4c887cbc 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -134,7 +134,10 @@ static int data(struct output *o, char *data_in, uint64_t length_in, char *outbuf, *c; ctx = o->internal; - outsize = strlen(ctx->header); + + outsize = 0; + if (ctx->header) + outsize = strlen(ctx->header); outbuf = calloc(1, outsize + 1 + 10000); /* FIXME: Use realloc(). */ if (outbuf == NULL) return SIGROK_ERR_MALLOC; diff --git a/output/output_vcd.c b/output/output_vcd.c index 76d662e2..a147f5a9 100644 --- a/output/output_vcd.c +++ b/output/output_vcd.c @@ -143,7 +143,9 @@ static int data(struct output *o, char *data_in, uint64_t length_in, char *outbuf, *c; ctx = o->internal; - outsize = strlen(ctx->header); + outsize = 0; + if (ctx->header) + outsize = strlen(ctx->header); outbuf = calloc(1, outsize + 1 + 10000); /* FIXME: Use realloc(). */ if (outbuf == NULL) return SIGROK_ERR_MALLOC;