[fix] Extractor falls out of scope
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Extractor was created and destroyed within the if scope, leading to a dereference error when trying to call the virtual writer methods.
This commit is contained in:
parent
86ab4a5050
commit
064c936f11
3 changed files with 12 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
.clangd/
|
||||
build/
|
||||
target/
|
||||
compile_commands.json
|
||||
|
||||
# Created by https://www.gitignore.io/api/vim,c++,emacs,ninja
|
||||
|
|
|
@ -106,17 +106,17 @@ ArchiveSpec Archive::check() {
|
|||
void Archive::extract(ExtractSpec extract_spec) {
|
||||
std::filesystem::path abs_path = std::filesystem::absolute(this->path);
|
||||
|
||||
std::unique_ptr<ArchiveExtractorSys> extractor;
|
||||
|
||||
if(extract_spec.make_dir) {
|
||||
ArchiveExtractorSys extractor{ArchiveExtractorSys{extract_spec.dirname}};
|
||||
logger::trace("Creating extract directory {}", extract_spec.dirname.string());
|
||||
ArchiveReaderSys reader{abs_path};
|
||||
extractor.extract_all(reader);
|
||||
extractor = std::unique_ptr<ArchiveExtractorSys>(new ArchiveExtractorSys{extract_spec.dirname});
|
||||
} else {
|
||||
ArchiveExtractorSys extractor{};
|
||||
logger::trace("Creating extract directory {}", extract_spec.dirname.string());
|
||||
ArchiveReaderSys reader{abs_path};
|
||||
extractor.extract_all(reader);
|
||||
extractor = std::unique_ptr<ArchiveExtractorSys>(new ArchiveExtractorSys{});
|
||||
}
|
||||
|
||||
ArchiveReaderSys reader{abs_path};
|
||||
extractor->extract_all(reader);
|
||||
}
|
||||
|
||||
} // namespace xwim
|
||||
|
|
|
@ -79,6 +79,8 @@ xwim::ArchiveExtractorSys::ArchiveExtractorSys(std::filesystem::path& root) {
|
|||
|
||||
this->writer = archive_write_disk_new();
|
||||
archive_write_disk_set_standard_lookup(this->writer);
|
||||
|
||||
logger::trace("Constructed ArchiveExtractorSys at {:p}", (void*) this->writer);
|
||||
}
|
||||
|
||||
xwim::ArchiveExtractorSys::ArchiveExtractorSys() {
|
||||
|
@ -86,6 +88,7 @@ xwim::ArchiveExtractorSys::ArchiveExtractorSys() {
|
|||
|
||||
this->writer = archive_write_disk_new();
|
||||
archive_write_disk_set_standard_lookup(this->writer);
|
||||
logger::trace("Constructed ArchiveExtractorSys at {:p}", (void*) this->writer);
|
||||
}
|
||||
|
||||
void xwim::ArchiveExtractorSys::extract_all(xwim::ArchiveReaderSys& reader) {
|
||||
|
@ -111,7 +114,7 @@ void xwim::ArchiveExtractorSys::extract_entry(xwim::ArchiveReaderSys& reader) {
|
|||
}
|
||||
|
||||
xwim::ArchiveExtractorSys::~ArchiveExtractorSys(){
|
||||
logger::trace("Destructing ArchiveExtractorSys");
|
||||
logger::trace("Destructing ArchiveExtractorSys at {:p}", (void*) this->writer);
|
||||
if(this->writer) {
|
||||
archive_write_close(this->writer);
|
||||
archive_write_free(this->writer);
|
||||
|
|
Loading…
Reference in a new issue