libdvbv5/dvb-file: Fix the logic for program found check
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 19 Nov 2013 16:41:00 +0000 (14:41 -0200)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 27 Nov 2013 11:24:40 +0000 (09:24 -0200)
The logic is broken, causing a crash. Fix it.

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

index d80d2a2..e7cc2dc 100644 (file)
@@ -987,7 +987,7 @@ static int get_program_and_store(struct dvb_v5_fe_parms *parms,
                                 int get_detected, int get_nit)
 {
        struct dvb_entry *entry;
-       int i, j;
+       int i, j, found = 0;
 
        /* Go to the last entry */
 
@@ -1001,11 +1001,13 @@ static int get_program_and_store(struct dvb_v5_fe_parms *parms,
                if (!dvb_scan_handler->program[i].pmt)
                        continue;
 
-               if (service_id == dvb_scan_handler->program[i].pat_pgm->service_id)
+               if (service_id == dvb_scan_handler->program[i].pat_pgm->service_id) {
+                       found = 1;
                        break;
+               }
        }
 
-       if (service_id != dvb_scan_handler->program[i].pat_pgm->service_id) {
+       if (!found) {
                fprintf(stderr, "Service ID %d not found on PMT!\n",
                        service_id);
                return 0;
@@ -1122,6 +1124,7 @@ int store_dvb_channel(struct dvb_file **dvb_file,
                if (!channel)
                        asprintf(&channel, "#%d", service->service_id);
 
+               dvb_log("Storing as channel %s", channel);
                vchannel = dvb_vchannel(dvb_scan_handler->nit, service->service_id);
 
                rc = get_program_and_store(parms, *dvb_file, dvb_scan_handler,