]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
asix-sigma: Remove stack-based alloc in download_capture()
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index c44bae7ab9bb3b7fde085a178795458ab9515abb..7e4b3caa79ce21ae8ca75d4adb3f7953dbdf2307 100644 (file)
@@ -1073,13 +1073,20 @@ static int download_capture(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc = sdi->priv;
        const int chunks_per_read = 32;
-       unsigned char buf[chunks_per_read * CHUNK_SIZE];
+       struct sigma_dram_line *dram_line;
+       unsigned char *buf;
        int bufsz, i, numchunks, newchunks;
        uint32_t stoppos, triggerpos;
        int triggerchunk, chunks_downloaded;
        struct sr_datafeed_packet packet;
        uint8_t modestatus;
 
+       dram_line = g_try_malloc0(chunks_per_read * sizeof(*dram_line));
+       if (!dram_line)
+               return FALSE;
+
+       buf = (unsigned char *)dram_line;
+
        sr_info("Downloading sample data.");
 
        /* Stop acquisition. */
@@ -1143,6 +1150,8 @@ static int download_capture(struct sr_dev_inst *sdi)
 
        dev_acquisition_stop(sdi, sdi);
 
+       g_free(dram_line);
+
        return TRUE;
 }