Fix potential memleak in MPNG_CHUNK_IDAT
This commit is contained in:
parent
833335464a
commit
651da5f51c
|
@ -234,32 +234,28 @@ bool png_decode(const void *userdata, size_t len,
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case MPNG_CHUNK_PLTE:
|
case MPNG_CHUNK_PLTE:
|
||||||
{
|
if (chunk.size % 3)
|
||||||
if (chunk.size % 3)
|
goto error;
|
||||||
goto error;
|
|
||||||
|
|
||||||
palette_len = chunk.size / 3;
|
palette_len = chunk.size / 3;
|
||||||
|
|
||||||
if (!mpng_read_plte(&ihdr, &chunk, pixels, palette, palette_len))
|
if (!mpng_read_plte(&ihdr, &chunk, pixels, palette, palette_len))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MPNG_CHUNK_TRNS:
|
case MPNG_CHUNK_TRNS:
|
||||||
{
|
if (format != FMT_ARGB8888 || !pixels || pixels != pixelsat)
|
||||||
if (format != FMT_ARGB8888 || !pixels || pixels != pixelsat)
|
goto error;
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (ihdr.color_type == 2)
|
if (ihdr.color_type == 2)
|
||||||
{
|
{
|
||||||
if (palette_len == 0)
|
if (palette_len == 0)
|
||||||
goto error;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
else if (ihdr.color_type == 3)
|
|
||||||
goto error;
|
|
||||||
else
|
|
||||||
goto error;
|
goto error;
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
else if (ihdr.color_type == 3)
|
||||||
|
goto error;
|
||||||
|
else
|
||||||
|
goto error;
|
||||||
break;
|
break;
|
||||||
case MPNG_CHUNK_IDAT:
|
case MPNG_CHUNK_IDAT:
|
||||||
{
|
{
|
||||||
|
@ -335,6 +331,9 @@ bool png_decode(const void *userdata, size_t len,
|
||||||
|
|
||||||
out = (uint8_t*)malloc(videofmt_byte_per_pixel(format) * ihdr.width * ihdr.height);
|
out = (uint8_t*)malloc(videofmt_byte_per_pixel(format) * ihdr.width * ihdr.height);
|
||||||
|
|
||||||
|
if (!out)
|
||||||
|
goto error;
|
||||||
|
|
||||||
/* TODO: deinterlace at random point */
|
/* TODO: deinterlace at random point */
|
||||||
|
|
||||||
/* run filters */
|
/* run filters */
|
||||||
|
|
Loading…
Reference in New Issue