Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRikard Falkeborn <rikard.falkeborn@gmail.com>2015-07-20 21:34:10 +0200
committerAllan McRae <allan@archlinux.org>2015-08-08 10:36:21 +1000
commit2d0e2bf2558698db242fbc382675ee00044c0d76 (patch)
tree9c5ebf2f2e3c5c3dbd3bc429ea5842f30c609782 /src
parentb8c9385b8bbe9ad8a904e4cc27966f1029e67765 (diff)
pacman/util.c: Fix memory leak if realloc fails
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/util.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index dd6e218a..3d71d8b0 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1449,11 +1449,14 @@ int multiselect_question(char *array, int count)
size_t len;
/* handle buffer not being large enough to read full line case */
while(*lastchar == '\0' && lastchar[-1] != '\n') {
+ char *new_response;
response_len += response_incr;
- response = realloc(response, response_len);
- if(!response) {
+ new_response = realloc(response, response_len);
+ if(!new_response) {
+ free(response);
return -1;
}
+ response = new_response;
lastchar = response + response_len - 1;
/* sentinel byte */
*lastchar = 1;