summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/delta.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2014-12-21 15:11:59 +0100
committerAllan McRae <allan@archlinux.org>2014-12-24 02:19:29 +0100
commitcd5e4b89f4564edb1926e18dd857a9d3842c17e4 (patch)
tree89b8674888a42a720063ab284759976481f30352 /lib/libalpm/delta.c
parente89223420796739a1c52e64fcbffc011085d0e52 (diff)
downloadpacman-cd5e4b89f4564edb1926e18dd857a9d3842c17e4.tar.gz
pacman-cd5e4b89f4564edb1926e18dd857a9d3842c17e4.tar.xz
_alpm_delta_parse: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/delta.c')
-rw-r--r--lib/libalpm/delta.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 23ca31d5..db6bb8e7 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -306,10 +306,10 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
/* start at index 1 -- match 0 is the entire match */
len = pmatch[1].rm_eo - pmatch[1].rm_so;
- STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, return NULL);
+ STRNDUP(delta->delta, &line[pmatch[1].rm_so], len, goto error);
len = pmatch[2].rm_eo - pmatch[2].rm_so;
- STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, return NULL);
+ STRNDUP(delta->delta_md5, &line[pmatch[2].rm_so], len, goto error);
len = pmatch[3].rm_eo - pmatch[3].rm_so;
if(len < sizeof(filesize)) {
@@ -319,12 +319,16 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
}
len = pmatch[4].rm_eo - pmatch[4].rm_so;
- STRNDUP(delta->from, &line[pmatch[4].rm_so], len, return NULL);
+ STRNDUP(delta->from, &line[pmatch[4].rm_so], len, goto error);
len = pmatch[5].rm_eo - pmatch[5].rm_so;
- STRNDUP(delta->to, &line[pmatch[5].rm_so], len, return NULL);
+ STRNDUP(delta->to, &line[pmatch[5].rm_so], len, goto error);
return delta;
+
+error:
+ _alpm_delta_free(delta);
+ return NULL;
}
#undef NUM_MATCHES