(RPNG) Cleanup read_chunk_header

This commit is contained in:
twinaphex 2020-08-22 17:18:32 +02:00
parent d6f22a7a4c
commit 73ed02b5f6
1 changed files with 7 additions and 7 deletions

View File

@ -919,16 +919,12 @@ error:
return NULL;
}
static enum png_chunk_type read_chunk_header(uint8_t *buf, uint8_t *buf_end,
uint32_t chunk_size)
static enum png_chunk_type read_chunk_header(
uint8_t *buf, uint32_t chunk_size)
{
unsigned i;
char type[4];
/* Check whether chunk will overflow the data buffer */
if (buf + 8 + chunk_size > buf_end)
return PNG_CHUNK_ERROR;
for (i = 0; i < 4; i++)
{
uint8_t byte = buf[i + 4];
@ -1018,7 +1014,11 @@ bool rpng_iterate_image(rpng_t *rpng)
chunk_size = dword_be(buf);
switch (read_chunk_header(buf, rpng->buff_end, chunk_size))
/* Check whether chunk will overflow the data buffer */
if (buf + 8 + chunk_size > rpng->buff_end)
return false;
switch (read_chunk_header(buf, chunk_size))
{
case PNG_CHUNK_NOOP:
default: