summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2011-08-18 09:42:20 +0200
committerDan McGee <dan@archlinux.org>2011-08-18 17:47:41 +0200
commitd18e600952015378c9ba79661597f1c01046f436 (patch)
tree4186d4273827560fbc8f76d8d96afad7d7c14d24
parent0745288c1441c73a0c6ce4279823d8363bcdc62f (diff)
downloadpacman-d18e600952015378c9ba79661597f1c01046f436.tar.gz
pacman-d18e600952015378c9ba79661597f1c01046f436.tar.xz
lib/libalpm/dload.c: Use STRDUP() instead of strdup()
Use the STRDUP macro instead of strdup() for the sake of better error handling on memory allocation failures. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/dload.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 3376ec40..5464740a 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -387,10 +387,12 @@ cleanup:
tempfile, destfile, strerror(errno));
ret = -1;
} else if(final_file) {
- *final_file = strdup(strrchr(destfile, '/') + 1);
+ STRDUP(*final_file, strrchr(destfile, '/') + 1,
+ RET_ERR(handle, ALPM_ERR_MEMORY, -1));
}
} else if(final_file) {
- *final_file = strdup(strrchr(tempfile, '/') + 1);
+ STRDUP(*final_file, strrchr(tempfile, '/') + 1,
+ RET_ERR(handle, ALPM_ERR_MEMORY, -1));
}
}
@@ -457,7 +459,7 @@ char SYMEXPORT *alpm_fetch_pkgurl(alpm_handle_t *handle, const char *url)
CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
payload->handle = handle;
- payload->fileurl = strdup(url);
+ STRDUP(payload->fileurl, url, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
payload->allow_resume = 1;
/* download the file */