summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_package.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2014-03-08 07:58:30 +0100
committerAllan McRae <allan@archlinux.org>2014-03-08 07:58:30 +0100
commitffdc2c5396903ec0dd2b7ab4623f7f7674827885 (patch)
tree1934e4c5234940b0694ef9f70ef71f0041d1f6d0 /lib/libalpm/be_package.c
parentf3a280bc67c0f2e7b57f3772599f989b0df4d945 (diff)
downloadpacman-ffdc2c5396903ec0dd2b7ab4623f7f7674827885.tar.gz
pacman-ffdc2c5396903ec0dd2b7ab4623f7f7674827885.tar.xz
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 <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_package.c')
-rw-r--r--lib/libalpm/be_package.c8
1 files changed, 3 insertions, 5 deletions
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';