alpm_dep_from_string: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
27506aba8f
commit
c6dd581ec5
1 changed files with 7 additions and 3 deletions
|
@ -473,7 +473,7 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
|
||||||
|
|
||||||
/* Note the extra space in ": " to avoid matching the epoch */
|
/* Note the extra space in ": " to avoid matching the epoch */
|
||||||
if((desc = strstr(depstring, ": ")) != NULL) {
|
if((desc = strstr(depstring, ": ")) != NULL) {
|
||||||
STRDUP(depend->desc, desc + 2, return NULL);
|
STRDUP(depend->desc, desc + 2, goto error);
|
||||||
deplen = desc - depstring;
|
deplen = desc - depstring;
|
||||||
} else {
|
} else {
|
||||||
/* no description- point desc at NULL at end of string for later use */
|
/* no description- point desc at NULL at end of string for later use */
|
||||||
|
@ -513,13 +513,17 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the right parts to the right places */
|
/* copy the right parts to the right places */
|
||||||
STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
|
STRNDUP(depend->name, depstring, ptr - depstring, goto error);
|
||||||
depend->name_hash = _alpm_hash_sdbm(depend->name);
|
depend->name_hash = _alpm_hash_sdbm(depend->name);
|
||||||
if(version) {
|
if(version) {
|
||||||
STRNDUP(depend->version, version, desc - version, return NULL);
|
STRNDUP(depend->version, version, desc - version, goto error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return depend;
|
return depend;
|
||||||
|
|
||||||
|
error:
|
||||||
|
alpm_dep_free(depend);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
|
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
|
||||||
|
|
Loading…
Add table
Reference in a new issue