session: fix another potential memory leak

This was reported by clang's scan-build.
This commit is contained in:
Gerhard Sittig 2018-02-10 10:12:51 +01:00
parent 972398f471
commit 499f5045dd
1 changed files with 3 additions and 1 deletions

View 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;