dvbinfo: check optarg

[email protected] (Jean-Paul Saman) Thu, 8 Jan 2015 09:29:05 +0100 (CET)
Newsgroups gmane.comp.video.videolan.libdvbpsi.devel
Message-ID <[email protected]>
libdvbpsi | branch: master | Jean-Paul Saman <[email protected]> | Wed Dec 24 13:15:09 2014 +0100| [708ed766472bb114cadcf305e8f403cd0304b81c] | committer: Jean-Paul Saman

dvbinfo: check optarg

> http://git.videolan.org/gitweb.cgi/libdvbpsi.git/?a=commit;h=708ed766472bb114cadcf305e8f403cd0304b81c
---

 examples/dvbinfo/dvbinfo.c |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/examples/dvbinfo/dvbinfo.c b/examples/dvbinfo/dvbinfo.c
index 5b17246..3ae3f70 100644
--- a/examples/dvbinfo/dvbinfo.c
+++ b/examples/dvbinfo/dvbinfo.c
@@ -609,13 +609,16 @@ int main(int argc, char **pp_argv)
 
             /* - tuning options - */
             case 'c':
-                param->threshold = strtoul(optarg, NULL, 10);
-                if (((errno == ERANGE) && (param->threshold == ULONG_MAX)) ||
-                    ((errno != 0) && (param->threshold == 0)))
+                if (optarg)
                 {
-                    fprintf(stderr, "Option --capturesize has invalid content %s\n", optarg);
-                    params_free(param);
-                    usage();
+                    param->threshold = strtoul(optarg, NULL, 10);
+                    if (((errno == ERANGE) && (param->threshold == ULONG_MAX)) ||
+                        ((errno != 0) && (param->threshold == 0)))
+                    {
+                        fprintf(stderr, "Option --capturesize has invalid content %s\n", optarg);
+                        params_free(param);
+                        usage();
+                    }
                 }
                 break;
 

_______________________________________________
libdvbpsi-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/libdvbpsi-devel