Skip to content

Commit

Permalink
too many open file bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Aug 9, 2024
1 parent ba53e25 commit 493d329
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ccode/archive-extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ int archive_is_archive(archive *data, char *path) {
archive_read_support_filter_all(data->archive);
archive_read_support_format_all(data->archive);
int result = archive_read_open_filename(data->archive, path, 10240);
archive_read_close(data->archive);
archive_read_free(data->archive);
return result == ARCHIVE_OK;
}

Expand All @@ -71,6 +73,9 @@ char** archive_list_files(archive *data, int* len) {
array_add(data->a,archive_entry_pathname(entry));
archive_read_data_skip(data->archive);
}
archive_read_close(data->archive);
archive_read_free(data->archive);

return array_get(data->a, len);
}

Expand Down Expand Up @@ -155,9 +160,10 @@ static void archive_extract_fn(archive *data, char *path, bool all) {
fwarning("Skip unsupported archive entry: %s", entry_path);
}
}
archive_read_close(data->archive);
archive_read_free(data->archive);
}



char* archive_readfile(archive *data, char *file_path) {
archive_load_archive(data);
struct archive_entry *entry;
Expand All @@ -182,6 +188,7 @@ char* archive_readfile(archive *data, char *file_path) {
break;
}
archive_read_close(data->archive);
archive_read_free(data->archive);
return ret;
}

Expand Down

0 comments on commit 493d329

Please sign in to comment.