summaryrefslogtreecommitdiffstats
path: root/libopkg/opkg.c
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:22:06 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:22:06 (EST)
commit9e85c59c8df6dd151fce6238811844d8d66ea1c0 (patch)
treefda715b0c88fb02029a6a42ed1768511a0ae4a0f /libopkg/opkg.c
parent38171e005d8bc496389bccdf8b9f8449b7b227a5 (diff)
opkg: Consolidate error reporting from opkg_conf_init and ensure return value is
checked in the appropriate places. opkg: Add a locking mechanism to prevent two instances of opkg being run at the same time. git-svn-id: http://opkg.googlecode.com/svn/trunk@130 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/opkg.c')
-rw-r--r--libopkg/opkg.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/libopkg/opkg.c b/libopkg/opkg.c
index 038469e..9f081cf 100644
--- a/libopkg/opkg.c
+++ b/libopkg/opkg.c
@@ -185,13 +185,28 @@ opkg_t *
opkg_new ()
{
opkg_t *opkg;
+ int err;
+
opkg = malloc (sizeof (opkg_t));
opkg->args = malloc (sizeof (args_t));
- args_init (opkg->args);
+ err = args_init (opkg->args);
+ if (err)
+ {
+ free (opkg->args);
+ free (opkg);
+ return NULL;
+ }
opkg->conf = malloc (sizeof (opkg_conf_t));
- opkg_conf_init (opkg->conf, opkg->args);
+ err = opkg_conf_init (opkg->conf, opkg->args);
+ if (err)
+ {
+ free (opkg->conf);
+ free (opkg->args);
+ free (opkg);
+ return NULL;
+ }
opkg_init_options_array (opkg->conf, &opkg->options);
return opkg;