From: Gerhard Sittig Date: Sun, 16 May 2021 12:45:47 +0000 (+0200) Subject: rigol-dg: free memory that was allocated by SCPI get routines X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ff85a7f0ab3cedf0b44b48e6f3e59da9c767d53b;p=libsigrok.git rigol-dg: free memory that was allocated by SCPI get routines 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. --- diff --git a/src/hardware/rigol-dg/api.c b/src/hardware/rigol-dg/api.c index ea8189b9..e8a3aadc 100644 --- a/src/hardware/rigol-dg/api.c +++ b/src/hardware/rigol-dg/api.c @@ -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; }