]> sigrok.org Git - libsigrok.git/commitdiff
session: fix another potential memory leak
authorGerhard Sittig <redacted>
Sat, 10 Feb 2018 09:12:51 +0000 (10:12 +0100)
committerGerhard Sittig <redacted>
Sat, 10 Feb 2018 14:32:03 +0000 (15:32 +0100)
This was reported by clang's scan-build.

src/session.c

index 0620b222b2cafa37b596d9011be2964d1320887b..fc7d0bc4b8dd908504bb05d99a1b291846235a5c 100644 (file)
@@ -1489,8 +1489,10 @@ SR_PRIV int sr_packet_copy(const struct sr_datafeed_packet *packet,
                logic_copy->length = logic->length;
                logic_copy->unitsize = logic->unitsize;
                logic_copy->data = g_malloc(logic->length * logic->unitsize);
-               if (!logic_copy->data)
+               if (!logic_copy->data) {
+                       g_free(logic_copy);
                        return SR_ERR;
+               }
                memcpy(logic_copy->data, logic->data, logic->length * logic->unitsize);
                (*copy)->payload = logic_copy;
                break;