summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-19 11:11:32 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-19 11:11:32 (EDT)
commitc91c1fa46dfc773090489f1802e4470a007b2cf7 (patch)
tree5c3d667b3e3f082e158f2cc0179f8336f8d68320 /src
parentda0e44cd2b78d4c1d4439c23a842fa3952ebe893 (diff)
opk: Fix a leak on error
Diffstat (limited to 'src')
-rw-r--r--src/opk.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/opk.c b/src/opk.c
index 45da6fd..7cd283d 100644
--- a/src/opk.c
+++ b/src/opk.c
@@ -71,21 +71,21 @@ opkg_opk_opk_init_outer(const char *file_name)
if (opk->file == NULL) {
fprintf(stderr, "Error: Failed to open file \"%s\"\n",
file_name);
- goto error0;
+ goto error1;
}
/* Initialize outer gzip decompressor. */
opk->outer_gzip = opkg_opk_gzip_init(&_opkg_opk_opk_file_read, opk);
if (opk->outer_gzip == NULL) {
fputs("Error: Failed to initialize\n", stderr);
- goto error1;
+ goto error2;
}
/* Initialize outer ustar unarchiver. */
opk->outer_ustar = opkg_opk_ustar_init(opk->outer_gzip);
if (opk->outer_ustar == NULL) {
fputs("Error: Failed to initialize\n", stderr);
- goto error2;
+ goto error3;
}
/* Check package version. */
@@ -93,31 +93,33 @@ opkg_opk_opk_init_outer(const char *file_name)
OPKG_OPK_OK) {
fputs("Error: Failed to find \"debian-binary\" in archive\n",
stderr);
- goto error3;
+ goto error4;
}
if (opkg_opk_ustar_read(opk->outer_ustar,
&opk->version_buffer, &opk->version_size) !=
OPKG_OPK_OK) {
fputs("Error: Failed to read \"debian-binary\" in archive\n",
stderr);
- goto error3;
+ goto error4;
}
if (opk->version_size < 4 || strncmp(opk->version_buffer, "2.", 2) != 0)
{
fputs("Error: Unsupported package version\n", stderr);
- goto error3;
+ goto error4;
}
opk->previously_printed = 0;
return opk;
- error3:
+ error4:
opkg_opk_ustar_free(opk->outer_ustar);
- error2:
+ error3:
opkg_opk_gzip_free(opk->outer_gzip);
- error1:
+ error2:
fclose(opk->file);
+ error1:
+ free(opk);
error0:
return NULL;
}