]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
cwc: fix potential leak spotted by EricV, and also bad var init
authorAdam Sutton <dev@adamsutton.me.uk>
Mon, 21 Apr 2014 18:51:39 +0000 (19:51 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Mon, 21 Apr 2014 18:53:55 +0000 (19:53 +0100)
src/descrambler/cwc.c

index e6a582553bee4fe1bd9aa69ef9095baee5284098..72ef301fd3f3b1d625f6e624b6e83b33b3353ff3 100755 (executable)
@@ -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;