mirror of https://github.com/OpenRCT2/OpenRCT2.git
* fix memleak * Replace deprecated functions and throw on error --------- Co-authored-by: ζeh Matt <5415177+ZehMatt@users.noreply.github.com>
This commit is contained in:
parent
fdbc3d29bb
commit
75fb313e5a
|
@ -169,13 +169,19 @@ public:
|
||||||
|
|
||||||
auto source = zip_source_buffer(_zip, writeBuffer.data(), writeBuffer.size(), 0);
|
auto source = zip_source_buffer(_zip, writeBuffer.data(), writeBuffer.size(), 0);
|
||||||
auto index = GetIndexFromPath(path);
|
auto index = GetIndexFromPath(path);
|
||||||
|
zip_int64_t res = 0;
|
||||||
if (index.has_value())
|
if (index.has_value())
|
||||||
{
|
{
|
||||||
zip_replace(_zip, index.value(), source);
|
res = zip_file_replace(_zip, index.value(), source, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
zip_add(_zip, path.data(), source);
|
res = zip_file_add(_zip, path.data(), source, 0);
|
||||||
|
}
|
||||||
|
if (res == -1)
|
||||||
|
{
|
||||||
|
zip_source_free(source);
|
||||||
|
throw std::runtime_error("Unable to set file contents.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue