summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/delta.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/delta.c')
-rw-r--r--lib/libalpm/delta.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index baa02b75..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
@@ -342,14 +346,18 @@ alpm_delta_t *_alpm_delta_dup(const alpm_delta_t *delta)
{
alpm_delta_t *newdelta;
CALLOC(newdelta, 1, sizeof(alpm_delta_t), return NULL);
- STRDUP(newdelta->delta, delta->delta, return NULL);
- STRDUP(newdelta->delta_md5, delta->delta_md5, return NULL);
- STRDUP(newdelta->from, delta->from, return NULL);
- STRDUP(newdelta->to, delta->to, return NULL);
+ STRDUP(newdelta->delta, delta->delta, goto error);
+ STRDUP(newdelta->delta_md5, delta->delta_md5, goto error);
+ STRDUP(newdelta->from, delta->from, goto error);
+ STRDUP(newdelta->to, delta->to, goto error);
newdelta->delta_size = delta->delta_size;
newdelta->download_size = delta->download_size;
return newdelta;
+
+error:
+ _alpm_delta_free(newdelta);
+ return NULL;
}
/* vim: set noet: */