unzip: check deflateInit and inflateInit results

This commit is contained in:
Megamouse 2023-10-25 20:06:12 +02:00
parent 132bb6db29
commit ecfa77f6e7

View File

@ -18,6 +18,10 @@ std::vector<u8> unzip(const void* src, usz size)
#pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wold-style-cast"
#endif #endif
int res = inflateInit2(&zs, 16 + 15); int res = inflateInit2(&zs, 16 + 15);
if (res != Z_OK)
{
return {};
}
#ifndef _MSC_VER #ifndef _MSC_VER
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
@ -79,6 +83,10 @@ bool unzip(const void* src, usz size, fs::file& out)
#pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wold-style-cast"
#endif #endif
int res = inflateInit(&strm); int res = inflateInit(&strm);
if (res != Z_OK)
{
return false;
}
#ifndef _MSC_VER #ifndef _MSC_VER
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
@ -138,6 +146,10 @@ std::vector<u8> zip(const void* src, usz size)
#pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wold-style-cast"
#endif #endif
int res = deflateInit2(&zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY); int res = deflateInit2(&zs, 9, Z_DEFLATED, 16 + 15, 9, Z_DEFAULT_STRATEGY);
if (res != Z_OK)
{
return {};
}
#ifndef _MSC_VER #ifndef _MSC_VER
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif