This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: dvbv5-zap: improve program exit code
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Sun Mar 17 07:18:27 2019 -0300

While testing the program with Valgrind, it would keep reporting
about non-freed data. The main reason is that, when called in
non-record and non-monitor mode, the while() loop doesn't check
for the timeout indication.

Solve that and be sure that all strdup() vars will be freed
too.

On my tests, on normal mode, on monitor mode and on record mode,
it now shows no memory leaks with Valgrind.

Having zero leaks in Valgrind is important mostly because we
don't want the libraries to leak. Having all memory allocated
internally at the program freed means that, if Valgrind will
report any memory leaks in the future, it would belong to
the library code.

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 utils/dvb/dvbv5-zap.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=8da72085b0731cc6a064f948bcd440a21440752d
diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index a5bba7313377..5f9cc6ae5e7b 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -338,6 +338,7 @@ static void do_timeout(int x)
                signal(SIGALRM, do_timeout);
        } else {
                /* something has gone wrong ... exit */
+               fprintf(stderr, "Forcing program stop due to timeout or 
terminate signal\n");
                exit(1);
        }
 }
@@ -803,6 +804,8 @@ static void set_signals(struct arguments *args)
        }
 }
 
+static char *default_dvr_pipe = "/tmp/dvr-pipe";
+
 int main(int argc, char **argv)
 {
        struct arguments args = {};
@@ -833,7 +836,6 @@ int main(int argc, char **argv)
        textdomain (PACKAGE);
 #endif
 
-       memset(&args, 0, sizeof(args));
        args.sat_number = -1;
        args.lna = LNA_AUTO;
        args.input_format = FILE_DVBV5;
@@ -1140,7 +1142,7 @@ int main(int argc, char **argv)
                        get_show_stats(&args, parms, 0);
        } else {
                /* Wait until timeout or being killed */
-               while (1) {
+               while (!timeout_flag) {
                        get_show_stats(&args, parms, 1);
                        usleep(1000000);
                }
@@ -1148,9 +1150,25 @@ int main(int argc, char **argv)
        err = 0;
 
 err:
+       dvb_dev_free(dvb);
+
+       /*
+        * Just to make Valgrind happier. It should be noticed
+        * That, if an error happens or if the program exits via
+        * timeout code at forced mode, it may not free those.
+        */
        if (args.confname)
                free(args.confname);
-       dvb_dev_free(dvb);
+       if (args.filename)
+               free(args.filename);
+       if (args.lnb_name)
+               free(args.lnb_name);
+       if (args.search)
+               free(args.search);
+       if (args.server)
+               free(args.search);
+       if (args.dvr_pipe != default_dvr_pipe)
+               free(args.dvr_pipe);
 
        return err;
 }

_______________________________________________
linuxtv-commits mailing list
[email protected]
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to