Don't return pointer to freed memory address.

This commit is contained in:
tastytea 2021-06-04 23:14:36 +02:00
parent cb2aee847f
commit 4026937f08
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 7 additions and 7 deletions

View File

@ -167,7 +167,7 @@ void close_file(struct archive *zipfile, const fs::path &filepath)
std::vector<std::string> list_spine(const fs::path &filepath)
{
const fs::path opf_file_path{
const auto opf_file_path{
[&filepath]
{
pugi::xml_document xml;
@ -176,15 +176,15 @@ std::vector<std::string> list_spine(const fs::path &filepath)
const auto result{xml.load_buffer(&container[0], container.size())};
if (result)
{
return xml.child("container")
.child("rootfiles")
.first_child()
.attribute("full-path")
.value();
return fs::path{xml.child("container")
.child("rootfiles")
.first_child()
.attribute("full-path")
.value()};
}
LOG(log::sev::error) << result.description() << '\n';
return "";
return fs::path{};
}()};
std::vector<std::string> spine_filepaths;