Skip to content

addData requires that data remains valid until close #152

@flomnes

Description

@flomnes

Short description

When adding some data through ZipArchive::addData, the buffer read/file write is delayed until ZipArchive::close is called. This is a problem if the user wants to write the data immediately and free the underlying memory.

I couldn't find any workaround.

Example from my project

    // Add data to an existing ZipArchive
    filename.clear() << folder << SEP << "areas.txt";
    study.pZipArchive->addData(filename.c_str(),
                               out.c_str(),
                               out.size());
    // out is freed
    // Do some more stuff not related to out & libzippp
    pZipArchive->close(); // <= Valgrind indicated an invalid read, with some garbage characters in the corresponding entry

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions