From: Adam Sutton Date: Mon, 21 Apr 2014 18:51:39 +0000 (+0100) Subject: cwc: fix potential leak spotted by EricV, and also bad var init X-Git-Tag: v4.1~2139 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54b7f9ca44b9e4c046cbb05bcea68cd369f389af;p=thirdparty%2Ftvheadend.git cwc: fix potential leak spotted by EricV, and also bad var init --- diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index e6a582553..72ef301fd 100755 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -463,10 +463,14 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq, uint1 { cwc_message_t *cm = malloc(sizeof(cwc_message_t)); uint8_t *buf = cm->cm_data; + int seq; - if (len < 3 || len + 12 > CWS_NETMSGSIZE) return -1; + if (len < 3 || len + 12 > CWS_NETMSGSIZE) { + free(cm); + return -1; + } - int seq = atomic_add(&cwc->cwc_seq, 1); + seq = atomic_add(&cwc->cwc_seq, 1); buf[0] = buf[1] = 0; buf[2] = (seq >> 8) & 0xff;