]> sigrok.org Git - libsigrok.git/commitdiff
Output: Fix invalid pointer dereferencing in vcd and gnuplot.
authorHåvard Espeland <redacted>
Tue, 4 May 2010 17:44:39 +0000 (19:44 +0200)
committerHåvard Espeland <redacted>
Tue, 4 May 2010 17:44:39 +0000 (19:44 +0200)
output/output_gnuplot.c
output/output_vcd.c

index 6e6edd4c5390a268710f4ddcbd036136410848e2..4c887cbcdba61e7aeb5378a80c08b6817c92c4a2 100644 (file)
@@ -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;
index 76d662e20e665b953b5cc4c82800af94ef4b19ad..a147f5a962a71056ee36b48d169f27962b2dfa23 100644 (file)
@@ -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;