From 9e85c59c8df6dd151fce6238811844d8d66ea1c0 Mon Sep 17 00:00:00 2001 From: ticktock35 Date: Mon, 15 Dec 2008 00:22:06 -0500 Subject: 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 --- (limited to 'libopkg/opkg.c') 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; -- cgit v0.9.1