libdvbv5: fix other error conditions for out of memory
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 29 Nov 2013 02:36:33 +0000 (00:36 -0200)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 29 Nov 2013 02:36:33 +0000 (00:36 -0200)
As Coverity points, there are other places where this error also occurs.

Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/libdvbv5/descriptors.c
lib/libdvbv5/descriptors/pat.c

index 7d44653..0253ef8 100644 (file)
@@ -136,9 +136,11 @@ void dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                        return;
                }
 
-               current = malloc(size);
-               if (!current)
+               current = calloc(1, size);
+               if (!current) {
                        dvb_perror("Out of memory");
+                       return;
+               }
                ptr += dvb_desc_init(ptr, current); /* the standard header was read */
                init(parms, ptr, current);
                if (!*head_desc)
index 2b6fd7f..4f7b949 100644 (file)
@@ -56,8 +56,10 @@ void dvb_table_pat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize
                struct dvb_table_pat_program *pgm;
 
                pgm = malloc(sizeof(struct dvb_table_pat_program));
-               if (!pgm)
+               if (!pgm) {
                        dvb_perror("Out of memory");
+                       return;
+               }
 
                memcpy(pgm, p, size);
                p += size;