]> sigrok.org Git - libsigrok.git/commitdiff
lecroy-xstream: Fix a potential memory leak.
authorUwe Hermann <redacted>
Sat, 19 May 2018 19:56:07 +0000 (21:56 +0200)
committerUwe Hermann <redacted>
Sat, 19 May 2018 20:01:26 +0000 (22:01 +0200)
Reported by scan-build:

  src/hardware/lecroy-xstream/protocol.c:680:12: warning: Potential leak of memory pointed to by 'analog.data'
                                  return SR_ERR;
                                         ^~~~~~

src/hardware/lecroy-xstream/protocol.c

index 03cf88ce7e73d42375c79b5644afdb6225e3a2fc..8a2129a71bb28ecd3b5291cba8f1a3e8bcdd8897 100644 (file)
@@ -676,8 +676,10 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data)
        } else {
                /* Update sample rate if needed. */
                if (state->sample_rate == 0)
-                       if (lecroy_xstream_update_sample_rate(sdi, analog.num_samples) != SR_OK)
+                       if (lecroy_xstream_update_sample_rate(sdi, analog.num_samples) != SR_OK) {
+                               g_free(analog.data);
                                return SR_ERR;
+                       }
        }
 
        /*