From: Gerhard Sittig Date: Sat, 10 Feb 2018 09:12:51 +0000 (+0100) Subject: session: fix another potential memory leak X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=499f5045dd505944319cdc388f6b3cd578ee9a6a;p=libsigrok.git session: fix another potential memory leak This was reported by clang's scan-build. --- diff --git a/src/session.c b/src/session.c index 0620b222..fc7d0bc4 100644 --- a/src/session.c +++ b/src/session.c @@ -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;