diff options
author | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-11-03 22:14:59 (EST) |
---|---|---|
committer | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2009-11-03 22:14:59 (EST) |
commit | 11af232b19155c76002b5ca1f2b0e89d75699d3a (patch) | |
tree | 5e113943ec678935d2ae1ac60b7e70bd49165f6e /libopkg/opkg_utils.c | |
parent | edf1b1964b565726a0b0f730b109e4491c7929b9 (diff) |
s/strdup/xstrdup/ - check memory allocations for failure.
git-svn-id: http://opkg.googlecode.com/svn/trunk@255 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/opkg_utils.c')
-rw-r--r-- | libopkg/opkg_utils.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/libopkg/opkg_utils.c b/libopkg/opkg_utils.c index 92291c4..ccc3496 100644 --- a/libopkg/opkg_utils.c +++ b/libopkg/opkg_utils.c @@ -23,6 +23,7 @@ #include "opkg_utils.h" #include "pkg.h" #include "pkg_hash.h" +#include "libbb/libbb.h" void print_pkg_status(pkg_t * pkg, FILE * file); @@ -87,7 +88,7 @@ char **read_raw_pkgs_from_stream(FILE *fp) if((scout = strchr(buf, '\n'))) *scout = '\0'; - raw[count++] = strdup(buf); + raw[count++] = xstrdup(buf); } raw = realloc(raw, (count + 1) * sizeof(char *)); @@ -163,14 +164,7 @@ void push_error_list(char * msg) return; } - e->errmsg = strdup(msg); - if (e->errmsg == NULL) { - fprintf(stderr, "%s: strdup: %s\n", - __FUNCTION__, strerror(errno)); - free(e); - return; - } - + e->errmsg = xstrdup(msg); e->next = NULL; if (error_list_head) { |