extcap: add null check (CID 1364683).
authorDario Lombardo <lomato@gmail.com>
Mon, 1 Aug 2016 20:01:27 +0000 (22:01 +0200)
committerAnders Broman <a.broman58@gmail.com>
Tue, 2 Aug 2016 04:16:45 +0000 (04:16 +0000)
Change-Id: I1d81d6f043fa695ed507cf733fffa832922a708c
Reviewed-on: https://code.wireshark.org/review/16832
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
extcap.c

index 0835f7ce19cbd57d208c3ee625a7fbb1b50d659d..7f67e1e1e14c647309943abc86b851e12ca20545 100644 (file)
--- a/extcap.c
+++ b/extcap.c
@@ -751,26 +751,29 @@ void extcap_if_cleanup(capture_options * capture_opts, gchar ** errormsg) {
         }
 #endif
 
-        if ( userdata->extcap_stderr != NULL )
-            overwrite_exitcode = TRUE;
-
-        if ( overwrite_exitcode || userdata->exitcode != 0 )
+        if ( userdata )
         {
-            if ( userdata->extcap_stderr != 0 )
+            if ( userdata->extcap_stderr != NULL )
+                overwrite_exitcode = TRUE;
+
+            if ( overwrite_exitcode || userdata->exitcode != 0 )
             {
-                if ( *errormsg == NULL )
-                    *errormsg = g_strdup_printf("Error by extcap pipe: %s", userdata->extcap_stderr);
-                else
+                if ( userdata->extcap_stderr != 0 )
                 {
-                    gchar * temp = g_strconcat ( *errormsg, "\nError by extcap pipe: " ,userdata->extcap_stderr, NULL );
-                    g_free(*errormsg);
-                    *errormsg = temp;
+                    if ( *errormsg == NULL )
+                        *errormsg = g_strdup_printf("Error by extcap pipe: %s", userdata->extcap_stderr);
+                    else
+                    {
+                        gchar * temp = g_strconcat ( *errormsg, "\nError by extcap pipe: " ,userdata->extcap_stderr, NULL );
+                        g_free(*errormsg);
+                        *errormsg = temp;
+                    }
+                    g_free (userdata->extcap_stderr );
                 }
-                g_free (userdata->extcap_stderr );
-            }
 
-            userdata->extcap_stderr = NULL;
-            userdata->exitcode = 0;
+                userdata->extcap_stderr = NULL;
+                userdata->exitcode = 0;
+            }
         }
 
         if (interface_opts.extcap_child_watch > 0)