libdvbv5/dvb-file: Don't leave memory leaks on channel store failure
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 19 Nov 2013 21:15:00 +0000 (19:15 -0200)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 27 Nov 2013 11:24:40 +0000 (09:24 -0200)
If channel store fails, the channel var should be freed.

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

index e7cc2dc..312cc63 100644 (file)
@@ -1010,10 +1010,9 @@ static int get_program_and_store(struct dvb_v5_fe_parms *parms,
        if (!found) {
                fprintf(stderr, "Service ID %d not found on PMT!\n",
                        service_id);
-               return 0;
+               return -1;
        }
 
-
        /* Create an entry to store the data */
        if (!dvb_file->first_entry) {
                dvb_file->first_entry = calloc(sizeof(*entry), 1);
@@ -1095,8 +1094,10 @@ int store_dvb_channel(struct dvb_file **dvb_file,
                                                d->program_number,
                                                channel, vchannel,
                                                get_detected, get_nit);
-                       if (rc < 0)
+                       if (rc < 0) {
+                               free(channel);
                                return rc;
+                       }
                }
                if (!dvb_scan_handler->sdt)
                        return 0;
@@ -1131,11 +1132,12 @@ int store_dvb_channel(struct dvb_file **dvb_file,
                                           service->service_id,
                                           channel, vchannel,
                                           get_detected, get_nit);
-               if (rc < 0)
+               if (rc < 0) {
+                       free(channel);
                        return rc;
+               }
        }
 
-
        return 0;
 }