diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-07-30 21:57:23 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-07-30 21:57:23 (EDT) |
commit | a05c2fd52744bc6306b38b4c7b6b6310e1ea74a4 (patch) | |
tree | 8192720df5a2001279b0dd58ded80c7ba5951bd2 | |
parent | d9dd69a6b8f15da2dfe6d5b41b3f5eb32d46e318 (diff) |
ustar: Add function to free member structure
-rw-r--r-- | opkg-opk/opk/read.c | 30 | ||||
-rw-r--r-- | opkg-opk/ustar.c | 6 | ||||
-rw-r--r-- | opkg-opk/ustar.h | 10 |
3 files changed, 30 insertions, 16 deletions
diff --git a/opkg-opk/opk/read.c b/opkg-opk/opk/read.c index e079b94..9d6bb40 100644 --- a/opkg-opk/opk/read.c +++ b/opkg-opk/opk/read.c @@ -171,7 +171,7 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) buffer += 2; } if (buffer[0] == '\0') { - free(member); + opkg_opk_ustar_member_free(member); continue; } @@ -179,7 +179,7 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) if (member->type != '-') { opkg_opk_error(_("Non-regular control files not " "supported")); - free(member); + opkg_opk_ustar_member_free(member); _opkg_opk_opk_read_free_inner(opk); if (opk->control_dir != NULL) { # pragma GCC diagnostic push @@ -198,7 +198,7 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) "-Wanalyzer-use-of-uninitialized-value" if (sprintf(path, "%s/%s", opk->control_dir, member->name) <= 0) { - free(member); + opkg_opk_ustar_member_free(member); _opkg_opk_opk_read_free_inner(opk); free(path); return OPKG_OPK_ERROR; @@ -215,7 +215,7 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) if (fp == NULL) { opkg_opk_error(_("Failed to extract control " "file")); - free(member); + opkg_opk_ustar_member_free(member); _opkg_opk_opk_read_free_inner(opk); # pragma GCC diagnostic push # pragma GCC diagnostic ignored \ @@ -243,7 +243,7 @@ _opkg_opk_opk_read_control(struct opkg_opk_opk *opk) } else { print = 0; } - free(member); + opkg_opk_ustar_member_free(member); if (print == 1 && opk->previously_printed == 1) { puts(""); } @@ -413,7 +413,7 @@ _opkg_opk_opk_read_data(struct opkg_opk_opk *opk) if (opk->print_data_head == NULL) { if (opk->list_data == 0) { - free(member); + opkg_opk_ustar_member_free(member); } continue; } @@ -423,12 +423,12 @@ _opkg_opk_opk_read_data(struct opkg_opk_opk *opk) OPKG_OPK_OK) { /* Name not requested for printing. */ if (opk->list_data == 0) { - free(member); + opkg_opk_ustar_member_free(member); } continue; } if (opk->list_data == 0) { - free(member); + opkg_opk_ustar_member_free(member); } if (opk->previously_printed == 1) { puts(""); @@ -544,7 +544,7 @@ _opkg_opk_opk_read_data(struct opkg_opk_opk *opk) } head = member; member = member->next; - free(head); + opkg_opk_ustar_member_free(head); } opk->previously_printed = 1; @@ -597,13 +597,13 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) goto out3; } if (strcmp(member->name, "debian-binary") != 0) { - free(member); + opkg_opk_ustar_member_free(member); opkg_opk_error(_("Failed to find \"debian-binary\" in archive") ); ret = OPKG_OPK_ERROR; goto out3; } - free(member); + opkg_opk_ustar_member_free(member); if (opkg_opk_ustar_read(opk->outer_ustar, &version_buffer, &version_size) != OPKG_OPK_OK) { @@ -625,12 +625,12 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) return OPKG_OPK_ERROR; } if (strcmp(member->name, "control.tar.gz") != 0) { - free(member); + opkg_opk_ustar_member_free(member); opkg_opk_error(_("Failed to find \"control.tar.gz\" in archive") ); return OPKG_OPK_ERROR; } - free(member); + opkg_opk_ustar_member_free(member); if (_opkg_opk_opk_read_control(opk) != OPKG_OPK_OK) { ret = OPKG_OPK_ERROR; goto out3; @@ -642,11 +642,11 @@ opkg_opk_opk_read(struct opkg_opk_opk *opk, const char *file_name) return OPKG_OPK_ERROR; } if (strcmp(member->name, "data.tar.gz") != 0) { - free(member); + opkg_opk_ustar_member_free(member); opkg_opk_error(_("Failed to find \"data.tar.gz\" in archive")); return OPKG_OPK_ERROR; } - free(member); + opkg_opk_ustar_member_free(member); if (_opkg_opk_opk_read_data(opk) != OPKG_OPK_OK) { ret = OPKG_OPK_ERROR; goto out3; diff --git a/opkg-opk/ustar.c b/opkg-opk/ustar.c index 5f6874a..5a202c7 100644 --- a/opkg-opk/ustar.c +++ b/opkg-opk/ustar.c @@ -440,6 +440,12 @@ opkg_opk_ustar_write_trailer(struct opkg_opk_ustar *ustar) } void +opkg_opk_ustar_member_free(struct opkg_opk_ustar_member *member) +{ + free(member); +} + +void opkg_opk_ustar_free(struct opkg_opk_ustar *ustar) { free(ustar); diff --git a/opkg-opk/ustar.h b/opkg-opk/ustar.h index 4a3dc1a..234964c 100644 --- a/opkg-opk/ustar.h +++ b/opkg-opk/ustar.h @@ -63,7 +63,7 @@ opkg_opk_ustar_init(struct opkg_opk_gzip *gzip); * Parameters: * - ustar: Archive structure. * - member: Address in which to store address of allocated member structure. - * Free with free(). + * Free with opkg_opk_ustar_member_free(). * Returns: * - OPKG_OPK_OK if a member was listed. More members may exist. * - OPKG_OPK_END if no more members exist. Parameter "member" is unchanged. @@ -107,6 +107,14 @@ int opkg_opk_ustar_write_trailer(struct opkg_opk_ustar *ustar); /* + * Frees a member structure. + * Parameters: + * - member: Member structure. + */ +void +opkg_opk_ustar_member_free(struct opkg_opk_ustar_member *member); + +/* * Frees an archive structure. * Parameters: * - ustar: Archive structure. |