]> sigrok.org Git - libsigrok.git/commitdiff
output_text: Allocate enough memory for output
authorHåvard Espeland <redacted>
Sat, 15 Jan 2011 15:10:57 +0000 (16:10 +0100)
committerHåvard Espeland <redacted>
Sat, 15 Jan 2011 15:12:12 +0000 (16:12 +0100)
output/output_text.c

index 2b362474738f0ad3baef752ed736c61df541dd02..6e2d4f08f46b0d02e1fda80b936fed0d08811b16 100644 (file)
@@ -194,8 +194,8 @@ static int data_bits(struct output *o, char *data_in, uint64_t length_in,
        ctx = o->internal;
        max_linelen = MAX_PROBENAME_LEN + 3 + ctx->samples_per_line
                        + ctx->samples_per_line / 8;
-       outsize = length_in / ctx->unitsize * ctx->num_enabled_probes
-                       / ctx->samples_per_line * max_linelen + 512;
+       outsize = (1 + (length_in / ctx->unitsize) / ctx->samples_per_line)
+            * (ctx->num_enabled_probes * max_linelen);
 
        if (!(outbuf = calloc(1, outsize + 1)))
                return SIGROK_ERR_MALLOC;