Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Jones <nathanj@insightbb.com>2007-12-07 16:56:16 -0500
committerDan McGee <dan@archlinux.org>2007-12-21 11:08:05 -0600
commitb43301428e50d006c9b94d1ced74f1f0775a04dc (patch)
treeff0f60e46d7e0b083396c339dbbe0b1c7e26fb77
parent9a6582a8fd2195ad5294d07ced62df56961200e8 (diff)
Fix memory leak in shortest_delta_path.
It is possible for the if statement to never succeed, causing path to never be freed. It is also possible for the if statement to succeed more than once per loop, which could have caused a segfault. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/delta.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 9be031a8..3d33c595 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -168,15 +168,15 @@ static alpm_list_t *shortest_delta_path(alpm_list_t *deltas,
/* If this vertex has already been visited in the path, go to the
* next vertex. */
- if(alpm_list_find_ptr(path, v))
+ if(alpm_list_find_ptr(path, v)) {
continue;
+ }
/* Once we find a vertex that starts at the 'from' version,
* recursively find the shortest path using the 'to' version of this
* current vertex as the 'from' version in the function call. */
if(strcmp(v->from, from) == 0) {
alpm_list_t *newpath = alpm_list_copy(path);
- alpm_list_free(path);
newpath = alpm_list_add(newpath, v);
newpath = shortest_delta_path(deltas, v->to, to, newpath);
@@ -195,6 +195,8 @@ static alpm_list_t *shortest_delta_path(alpm_list_t *deltas,
}
}
+ alpm_list_free(path);
+
return(shortest);
}