]> sigrok.org Git - libsigrok.git/commitdiff
rigol-dg: free memory that was allocated by SCPI get routines
authorGerhard Sittig <redacted>
Sun, 16 May 2021 12:45:47 +0000 (14:45 +0200)
committerGerhard Sittig <redacted>
Sat, 22 May 2021 06:06:58 +0000 (08:06 +0200)
The SCPI get routines may allocate memory for response data which
callers have to free after use.

Move an existing release call to an earlier location, to avoid leaking
memory when an error path is taken.

This addresses part of bug #1683.

src/hardware/rigol-dg/api.c

index ea8189b944a4eb3085486b1fa5b7aa823a687433..e8a3aadc8acd4ea2fd8edaa2824bb114abb42f31 100644 (file)
@@ -780,6 +780,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                        devc->counter_enabled = TRUE;
                else
                        devc->counter_enabled = FALSE;
+               g_free(response);
 
                if (!devc->counter_enabled) {
                        /*
@@ -834,8 +835,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
                }
        }
 
-       g_free(response);
-
        return ret;
 }