mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-12 07:14:03 +00:00
Fix M_SaveBitmap stream buffer size
- credits to dpJudas for the solution
This commit is contained in:
parent
fc3a2e2ad1
commit
3e10e3f551
1 changed files with 11 additions and 12 deletions
|
@ -54,7 +54,7 @@
|
|||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
// The maximum size of an IDAT chunk ZDoom will write. This is also the
|
||||
// size of the compression buffer it allocates on the stack.
|
||||
// size of the compression buffer it allocates on the heap.
|
||||
#define PNG_WRITE_SIZE 32768
|
||||
|
||||
// Set this to 1 to use a simple heuristic to select the filter to apply
|
||||
|
@ -926,8 +926,7 @@ bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height
|
|||
temprow[i] = &temprow_storage[temprow_size * i];
|
||||
}
|
||||
|
||||
TArray<Byte> array(PNG_WRITE_SIZE, true);
|
||||
auto buffer = array.data();
|
||||
TArray<Byte> buffer(PNG_WRITE_SIZE, true);
|
||||
z_stream stream;
|
||||
int err;
|
||||
int y;
|
||||
|
@ -944,8 +943,8 @@ bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height
|
|||
}
|
||||
|
||||
y = height;
|
||||
stream.next_out = buffer;
|
||||
stream.avail_out = sizeof(buffer);
|
||||
stream.next_out = buffer.data();
|
||||
stream.avail_out = buffer.size();
|
||||
|
||||
temprow[0][0] = 0;
|
||||
#if USE_FILTER_HEURISTIC
|
||||
|
@ -1007,12 +1006,12 @@ bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height
|
|||
}
|
||||
while (stream.avail_out == 0)
|
||||
{
|
||||
if (!WriteIDAT (file, buffer, sizeof(buffer)))
|
||||
if (!WriteIDAT (file, buffer.data(), buffer.size()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
stream.next_out = buffer;
|
||||
stream.avail_out = sizeof(buffer);
|
||||
stream.next_out = buffer.data();
|
||||
stream.avail_out = buffer.size();
|
||||
if (stream.avail_in != 0)
|
||||
{
|
||||
err = deflate (&stream, (y == 0) ? Z_FINISH : 0);
|
||||
|
@ -1033,12 +1032,12 @@ bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height
|
|||
}
|
||||
if (stream.avail_out == 0)
|
||||
{
|
||||
if (!WriteIDAT (file, buffer, sizeof(buffer)))
|
||||
if (!WriteIDAT (file, buffer.data(), buffer.size()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
stream.next_out = buffer;
|
||||
stream.avail_out = sizeof(buffer);
|
||||
stream.next_out = buffer.data();
|
||||
stream.avail_out = buffer.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1048,7 +1047,7 @@ bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height
|
|||
{
|
||||
return false;
|
||||
}
|
||||
return WriteIDAT (file, buffer, sizeof(buffer)-stream.avail_out);
|
||||
return WriteIDAT (file, buffer.data(), buffer.size() - stream.avail_out);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue