libdvbv5: Fix other error conditions for out of memory
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Thu, 28 Nov 2013 11:58:05 +0000 (09:58 -0200)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Thu, 28 Nov 2013 11:59:33 +0000 (09:59 -0200)
As Coverity points, there are other places where this error also occurs.

Fix all of them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/libdvbv5/descriptors/desc_logical_channel.c
lib/libdvbv5/descriptors/desc_partial_reception.c
lib/libdvbv5/descriptors/nit.c
lib/libdvbv5/dvb-scan.c

index 3f18c69..5eb5855 100644 (file)
@@ -36,8 +36,10 @@ void dvb_desc_logical_channel_init(struct dvb_v5_fe_parms *parms,
        int i;
 
        d->lcn = malloc(d->length);
-       if (!d->lcn)
+       if (!d->lcn) {
                dvb_perror("Out of memory!");
+               return;
+       }
 
        memcpy(d->lcn, p, d->length);
 
index 41bf428..9471772 100644 (file)
@@ -33,8 +33,10 @@ void isdb_desc_partial_reception_init(struct dvb_v5_fe_parms *parms,
        int i;
 
        d->partial_reception = malloc(d->length);
-       if (!d->partial_reception)
+       if (!d->partial_reception) {
                dvb_perror("Out of memory!");
+               return;
+       }
 
        memcpy(d->partial_reception, p, d->length);
 
index 97865d2..b1bbfab 100644 (file)
@@ -93,8 +93,10 @@ void dvb_table_nit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
                struct dvb_table_nit_transport *transport;
 
                transport = malloc(sizeof(struct dvb_table_nit_transport));
-               if (!transport)
+               if (!transport) {
                        dvb_perror("Out of memory");
+                       return;
+               }
                memcpy(transport, p, size);
                p += size;
 
index 978975e..639e669 100644 (file)
@@ -124,8 +124,11 @@ int dvb_read_section_with_id(struct dvb_v5_fe_parms *parms, int dmx_fd,
                dvb_log("Parsing table ID %d, program ID %d", tid, pid);
 
        buf = malloc(DVB_MAX_PAYLOAD_PACKET_SIZE);
-       if (!buf)
+       if (!buf) {
                dvb_perror("Out of memory");
+               dvb_dmx_stop(dmx_fd);
+               return -1;
+       }
        while (1) {
                int available;
                ssize_t buf_length = 0;