summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-01-28 19:55:39 +1100
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-01-28 19:55:39 +1100
commit206fddad198c18daeeac070893ed8f08fa511042 (patch)
treefcca7f4a49cc1b2dc400a3d20ba8a16e15866f64
parent81847cec366aa54431c38367a291c9e332c93803 (diff)
feat(png): Confirm tinf_uncompress for IDAT handler return's value
-rw-r--r--src/format/image/png.c10
1 files changed, 7 insertions, 3 deletions
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;
}