From 206fddad198c18daeeac070893ed8f08fa511042 Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Wed, 28 Jan 2026 19:55:39 +1100 Subject: feat(png): Confirm tinf_uncompress for IDAT handler return's value --- src/format/image/png.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/format/image/png.c') diff --git a/src/format/image/png.c b/src/format/image/png.c index ef30dcd..89891d7 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -135,8 +135,8 @@ ff_result ff_png_data_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) // Getting the size is weird cause it could the sample count // could be different based on color type and bit depth - // TODO: Calculate properly - size_t uncompressed_size = ctx->width * ctx->height; // WIP based size + // Update: Now we have a bpp helper function + size_t uncompressed_size = ctx->width * ctx->height * ff_png_bpp(ctx); uncompressed_data = malloc(uncompressed_size); @@ -145,7 +145,11 @@ ff_result ff_png_data_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) return FF_RESULT_ERROR_MEMORY_ALLOCATION; } - tinf_uncompress(uncompressed_data, uncompressed_size, buf, len); + if (tinf_uncompress(uncompressed_data, uncompressed_size, buf, len) != TINF_OK) { + ff_dprintf("png: failed to uncompress IDAT data\n"); + free(uncompressed_data); + return FF_RESULT_ERROR_DECOMPRESSION_FAILURE; + } return FF_RESULT_WARN_NO_IMPL; } -- cgit v1.2.3