mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-11-13 12:17:10 +00:00
fixed a memory leak in (de)compress_string
This commit is contained in:
4
util.cpp
4
util.cpp
@@ -737,6 +737,7 @@ EX string compress_string(string s) {
|
||||
if(deflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2");
|
||||
println(hlog, "deflate ok");
|
||||
string out(&buf[0], (char*)(strm.next_out) - &buf[0]);
|
||||
deflateEnd(&strm);
|
||||
println(hlog, isize(s), " -> ", isize(out));
|
||||
return out;
|
||||
}
|
||||
@@ -753,8 +754,9 @@ EX string decompress_string(string s) {
|
||||
vector<char> buf(10000000, 0);
|
||||
strm.avail_out = 10000000;
|
||||
strm.next_out = (Bytef*) &buf[0];
|
||||
if(inflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2");
|
||||
if(inflate(&strm, Z_FINISH) != Z_STREAM_END) throw hr_exception("z-error-2");
|
||||
string out(&buf[0], (char*)(strm.next_out) - &buf[0]);
|
||||
inflateEnd(&strm);
|
||||
println(hlog, isize(s), " -> ", isize(out));
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user