[pacman-dev] [PATCH 1/4] pacsort: fix memory leak
Signed-off-by: Allan McRae <allan@archlinux.org> --- src/util/pacsort.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/pacsort.c b/src/util/pacsort.c index 665f218..c59ba13 100644 --- a/src/util/pacsort.c +++ b/src/util/pacsort.c @@ -227,6 +227,7 @@ static struct input_t *input_new(const char *path, int pathlen) in->data = strndup(path, pathlen); if(in->data == NULL) { + free(in); return NULL; } -- 2.2.1
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/sync.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 3664675..e19655d 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -736,11 +736,11 @@ static int apply_deltas(alpm_handle_t *handle) } else { /* len = cachedir len + from len + '/' + null */ len = strlen(cachedir) + strlen(d->from) + 2; - MALLOC(from, len, RET_ERR(handle, ALPM_ERR_MEMORY, 1)); + MALLOC(from, len, free(delta); RET_ERR(handle, ALPM_ERR_MEMORY, 1)); snprintf(from, len, "%s/%s", cachedir, d->from); } len = strlen(cachedir) + strlen(d->to) + 2; - MALLOC(to, len, free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1)); + MALLOC(to, len, free(delta); free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1)); snprintf(to, len, "%s/%s", cachedir, d->to); /* build the patch command */ -- 2.2.1
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/deps.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index d105a32..2a21443 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -614,6 +614,8 @@ int _alpm_recursedeps(alpm_db_t *db, alpm_list_t **targs, int include_explicit) deppkg->name); /* add it to the target list */ if(_alpm_pkg_dup(deppkg, ©)) { + /* we return memory on "non-fatal" error in _alpm_pkg_dup */ + _alpm_pkg_free(copy); return -1; } *targs = alpm_list_add(*targs, copy); -- 2.2.1
Signed-off-by: Allan McRae <allan@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
participants (1)
-
Allan McRae