From e273a9040e10c1297c758fe35eb522bd5470e708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Espeland?= Date: Tue, 4 May 2010 19:44:39 +0200 Subject: [PATCH] Output: Fix invalid pointer dereferencing in vcd and gnuplot. --- output/output_gnuplot.c | 5 ++++- output/output_vcd.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) 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;