libopkg: add some checks for NULL strings
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:10:48 +0000 (05:10 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:10:48 +0000 (05:10 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@78 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg.c

index f72bd78914a319b97568cc90dd036518c1eb64bf..b4aff139b3b53b66721e988ae4244c4412c4dde9 100644 (file)
@@ -131,14 +131,23 @@ opkg_read_config_files (opkg_t *opkg)
   a->multiple_providers = c->multiple_providers;
   a->verbosity = c->verbosity;
 
-  if (a->offline_root) free (a->offline_root);
-  a->offline_root = strdup (c->offline_root);
+  if (c->offline_root)
+  {
+    if (a->offline_root) free (a->offline_root);
+    a->offline_root = strdup (c->offline_root);
+  }
 
-  if (a->offline_root_pre_script_cmd) free (a->offline_root_pre_script_cmd);
-  a->offline_root_pre_script_cmd = strdup (c->offline_root_pre_script_cmd);
+  if (c->offline_root_pre_script_cmd)
+  {
+    if (a->offline_root_pre_script_cmd) free (a->offline_root_pre_script_cmd);
+    a->offline_root_pre_script_cmd = strdup (c->offline_root_pre_script_cmd);
+  }
 
-  if (a->offline_root_post_script_cmd) free (a->offline_root_post_script_cmd);
-  a->offline_root_post_script_cmd = strdup (c->offline_root_post_script_cmd);
+  if (c->offline_root_post_script_cmd)
+  {
+    if (a->offline_root_post_script_cmd) free (a->offline_root_post_script_cmd);
+    a->offline_root_post_script_cmd = strdup (c->offline_root_post_script_cmd);
+  }
 
   /* throw away old opkg_conf and start again */
   opkg_conf_deinit (opkg->conf);