X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=output%2Ftext%2Fhex.c;h=cfe3bfb9e7a34943960c919b9f8cbff1ab69fcdc;hb=133a37bfba1a7e1423716b2b872d3bb82a2e64d9;hp=964cb9ccb69e69e0c7ca676b4d417a8f3de53ae8;hpb=cd853ff0b2b0ad2643d65e73159661e1a3c6bc66;p=libsigrok.git diff --git a/output/text/hex.c b/output/text/hex.c index 964cb9cc..cfe3bfb9 100644 --- a/output/text/hex.c +++ b/output/text/hex.c @@ -22,6 +22,7 @@ #include #include #include "sigrok.h" +#include "sigrok-internal.h" #include "text.h" SR_PRIV int init_hex(struct sr_output *o) @@ -44,14 +45,16 @@ SR_PRIV int data_hex(struct sr_output *o, const char *data_in, outsize = length_in / ctx->unitsize * ctx->num_enabled_probes / ctx->samples_per_line * max_linelen + 512; - if (!(outbuf = calloc(1, outsize + 1))) + if (!(outbuf = g_try_malloc0(outsize + 1))) { + sr_err("hex out: %s: outbuf malloc failed", __func__); return SR_ERR_MALLOC; + } outbuf[0] = '\0'; if (ctx->header) { /* The header is still here, this must be the first packet. */ strncpy(outbuf, ctx->header, outsize); - free(ctx->header); + g_free(ctx->header); ctx->header = NULL; }