[pacman-dev] [PATCH 4/4] Initialize memory to prevent issues when freeing on error
Allan McRae
allan at archlinux.org
Wed Dec 24 02:14:03 UTC 2014
Signed-off-by: Allan McRae <allan at archlinux.org>
---
lib/libalpm/conflict.c | 4 ++--
lib/libalpm/deps.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 40cbb95..c886f78 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -48,7 +48,7 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
{
alpm_conflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_conflict_t), return NULL);
+ CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
conflict->package1_hash = pkg1->name_hash;
conflict->package2_hash = pkg2->name_hash;
@@ -273,7 +273,7 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
{
alpm_fileconflict_t *conflict;
- MALLOC(conflict, sizeof(alpm_fileconflict_t), goto error);
+ CALLOC(conflict, 1, sizeof(alpm_fileconflict_t), goto error);
STRDUP(conflict->target, pkg1->name, goto error);
STRDUP(conflict->file, filestr, goto error);
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 2a21443..d4fbf95 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -48,7 +48,7 @@ static alpm_depmissing_t *depmiss_new(const char *target, alpm_depend_t *dep,
{
alpm_depmissing_t *miss;
- MALLOC(miss, sizeof(alpm_depmissing_t), return NULL);
+ CALLOC(miss, 1, sizeof(alpm_depmissing_t), return NULL);
STRDUP(miss->target, target, goto error);
miss->depend = _alpm_dep_dup(dep);
@@ -469,7 +469,7 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
return NULL;
}
- MALLOC(depend, sizeof(alpm_depend_t), return NULL);
+ CALLOC(depend, 1, sizeof(alpm_depend_t), return NULL);
/* Note the extra space in ": " to avoid matching the epoch */
if((desc = strstr(depstring, ": ")) != NULL) {
--
2.2.1
More information about the pacman-dev
mailing list