From ffdc2c5396903ec0dd2b7ab4623f7f7674827885 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 8 Mar 2014 16:58:30 +1000 Subject: Use MALLOC throughtout libalpm Use MALLOC instead of malloc for safety in libalpm. Some changes are pure refactoring, but for others this provides a success check for memory allocation. Signed-off-by: Allan McRae --- lib/libalpm/be_package.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/libalpm/be_package.c') diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c index 3c354846..dc2e0720 100644 --- a/lib/libalpm/be_package.c +++ b/lib/libalpm/be_package.c @@ -39,6 +39,7 @@ #include "package.h" #include "deps.h" #include "filelist.h" +#include "util.h" struct package_changelog { struct archive *archive; @@ -404,11 +405,8 @@ static int add_entry_to_files_list(alpm_pkg_t *pkg, size_t *files_size, * Other code relies on it to detect directories so add it here.*/ if(type == AE_IFDIR && path[pathlen - 1] != '/') { /* 2 = 1 for / + 1 for \0 */ - char *newpath = malloc(pathlen + 2); - if (!newpath) { - _alpm_alloc_fail(pathlen + 2); - return -1; - } + char *newpath; + MALLOC(newpath, pathlen + 2, return -1); strcpy(newpath, path); newpath[pathlen] = '/'; newpath[pathlen + 1] = '\0'; -- cgit v1.2.3