lib/archive.c: fixed memleaks in error paths; misc cleanups.
This commit is contained in:
parent
6795e840d6
commit
71a602fd27
@ -132,23 +132,24 @@ xbps_archive_get_dictionary(struct archive *ar, struct archive_entry *entry)
|
|||||||
|
|
||||||
/* If blob is already a dictionary we are done */
|
/* If blob is already a dictionary we are done */
|
||||||
d = xbps_dictionary_internalize(buf);
|
d = xbps_dictionary_internalize(buf);
|
||||||
if (xbps_object_type(d) == XBPS_TYPE_DICTIONARY)
|
if (xbps_object_type(d) == XBPS_TYPE_DICTIONARY) {
|
||||||
goto out;
|
free(buf);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try to uncompress blob */
|
/* Try to uncompress blob */
|
||||||
uncomp_buf = uncompress_plist_data(buf, buflen);
|
uncomp_buf = uncompress_plist_data(buf, buflen);
|
||||||
if (uncomp_buf == NULL) {
|
if (uncomp_buf == NULL) {
|
||||||
/* Error while decompressing */
|
/* Error while decompressing */
|
||||||
free(buf);
|
|
||||||
free(uncomp_buf);
|
free(uncomp_buf);
|
||||||
return NULL;
|
xbps_object_release(d);
|
||||||
|
d = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* We have the uncompressed data */
|
/* We have the uncompressed data */
|
||||||
d = xbps_dictionary_internalize(uncomp_buf);
|
d = xbps_dictionary_internalize(uncomp_buf);
|
||||||
free(uncomp_buf);
|
free(uncomp_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
free(buf);
|
free(buf);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@ -180,12 +181,14 @@ xbps_archive_append_buf(struct archive *ar, const void *buf, const size_t buflen
|
|||||||
archive_entry_set_mtime(entry, tm, 0);
|
archive_entry_set_mtime(entry, tm, 0);
|
||||||
archive_entry_set_ctime(entry, tm, 0);
|
archive_entry_set_ctime(entry, tm, 0);
|
||||||
|
|
||||||
if (archive_write_header(ar, entry) != ARCHIVE_OK)
|
if (archive_write_header(ar, entry) != ARCHIVE_OK) {
|
||||||
|
archive_entry_free(entry);
|
||||||
return archive_errno(ar);
|
return archive_errno(ar);
|
||||||
|
}
|
||||||
if (archive_write_data(ar, buf, buflen) != ARCHIVE_OK)
|
if (archive_write_data(ar, buf, buflen) != ARCHIVE_OK) {
|
||||||
|
archive_entry_free(entry);
|
||||||
return archive_errno(ar);
|
return archive_errno(ar);
|
||||||
|
}
|
||||||
archive_write_finish_entry(ar);
|
archive_write_finish_entry(ar);
|
||||||
archive_entry_free(entry);
|
archive_entry_free(entry);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user