]> sigrok.org Git - libsigrok.git/blobdiff - src/output/csv.c
csv: Fix a segfault due to a g_malloc() allocating too few bytes.
[libsigrok.git] / src / output / csv.c
index 9c6d8d5f70041057098370e89340922047988fda..e14984ef785379591b32b16f150e1e9dc3533d55 100644 (file)
@@ -236,7 +236,7 @@ static GString *gen_header(const struct sr_output *o,
                sr_info("Set sample period to %" PRIu64 " %s",
                        ctx->period, ctx->xlabel);
        }
-       ctx->title = o->sdi->driver->longname;
+       ctx->title = (o->sdi && o->sdi->driver) ? o->sdi->driver->longname : "unknown";
 
        /* Some metadata */
        if (ctx->header && !ctx->did_header) {
@@ -319,7 +319,7 @@ static void process_analog(struct context *ctx,
        num_channels = g_slist_length(meaning->channels);
        ctx->channels_seen += num_channels;
        sr_dbg("Processing packet of %u analog channels", num_channels);
-       fdata = g_malloc(analog->num_samples * num_channels);
+       fdata = g_malloc(analog->num_samples * num_channels * sizeof(float));
        if ((ret = sr_analog_to_float(analog, fdata)) != SR_OK)
                sr_warn("Problems converting data to floating point values.");