fix leak of cloned entry

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2025-12-14 00:20:24 +02:00
parent 7eaaf6a224
commit f05fd4da2b

View File

@@ -23,6 +23,7 @@
#include <archive_entry.h>
#include <QDir>
#include <QFileInfo>
#include <memory>
namespace MMCZip {
QStringList ArchiveReader::getFiles()
@@ -130,8 +131,10 @@ static int copy_data(struct archive* ar, struct archive* aw, bool notBlock = fal
bool ArchiveReader::File::writeFile(archive* out, QString targetFileName, bool notBlock)
{
auto entry = m_entry;
std::unique_ptr<archive_entry, decltype(&archive_entry_free)> entryClone(nullptr, &archive_entry_free);
if (!targetFileName.isEmpty()) {
entry = archive_entry_clone(m_entry);
entryClone.reset(archive_entry_clone(m_entry));
entry = entryClone.get();
auto nameUtf8 = targetFileName.toUtf8();
archive_entry_set_pathname(entry, nameUtf8.constData());
}