From 4026937f0863eb282b59f458f48cf842306128fb Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 4 Jun 2021 23:14:36 +0200 Subject: [PATCH] Don't return pointer to freed memory address. --- src/zip.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/zip.cpp b/src/zip.cpp index 436bb2c..1c6f858 100644 --- a/src/zip.cpp +++ b/src/zip.cpp @@ -167,7 +167,7 @@ void close_file(struct archive *zipfile, const fs::path &filepath) std::vector 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 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 spine_filepaths;