From 922c14bca8e95e1d507ece63e0464f45dc92443c Mon Sep 17 00:00:00 2001 From: ticktock35 Date: Mon, 15 Dec 2008 05:10:48 +0000 Subject: [PATCH] libopkg: add some checks for NULL strings git-svn-id: http://opkg.googlecode.com/svn/trunk@78 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- libopkg/opkg.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libopkg/opkg.c b/libopkg/opkg.c index f72bd78..b4aff13 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -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); -- 2.30.2