From: HÃ¥vard Espeland Date: Sat, 15 Jan 2011 15:10:57 +0000 (+0100) Subject: output_text: Allocate enough memory for output X-Git-Tag: libsigrok-0.1.0~428 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=3aa403e858a490aee17c23c11d3a09cdd4eb324d;p=libsigrok.git output_text: Allocate enough memory for output --- diff --git a/output/output_text.c b/output/output_text.c index 2b362474..6e2d4f08 100644 --- a/output/output_text.c +++ b/output/output_text.c @@ -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;