diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-04-14 11:09:33 +1000 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-04-14 11:09:33 +1000 |
| commit | 2c526ed41bf81a3c7e0438661fd87d2480221f34 (patch) | |
| tree | 521631e222854dd7f1613844b7205a81b5060c48 /src | |
| parent | 097ad322e0cbe5ca72a3d7c1938f2925547c196b (diff) | |
fix(png): IDAT uncompressed size and zlib header skip
Diffstat (limited to 'src')
| -rw-r--r-- | src/common.c | 3 | ||||
| -rw-r--r-- | src/format/image/png.c | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/common.c b/src/common.c index b9f7563..9307889 100644 --- a/src/common.c +++ b/src/common.c @@ -1,3 +1,4 @@ +#include <tinyff/stream.h> #include <tinyff/dbg.h> #include <tinyff/common.h> @@ -22,7 +23,7 @@ ff_ctx* ff_init(ff_allocator* allocator) if (!ctx) return NULL; ctx->ff_debug_enabled = FF_DISABLE; - ctx->ff_debug_stream = NULL; + ctx->ff_debug_stream = FF_NULL_STREAM; ctx->allocator = *allocator; diff --git a/src/format/image/png.c b/src/format/image/png.c index c5dcb4d..1004b2a 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -242,7 +242,7 @@ ff_result ff_png_data_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx // Getting the size is weird cause it could the sample count // could be different based on color type and bit depth - size_t uncompressed_size = png_ctx->width * png_ctx->height * ff_png_bpp(png_ctx); + size_t uncompressed_size = png_ctx->height * (1 + png_ctx->width * ff_png_bpp(png_ctx)); uncompressed_data = ctx->allocator.ff_alloc(uncompressed_size); @@ -254,7 +254,7 @@ ff_result ff_png_data_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx } unsigned int out_size = (unsigned int)uncompressed_size; - if (tinf_uncompress(uncompressed_data, &out_size, buf, len) != TINF_OK) { + if (tinf_uncompress(uncompressed_data, &out_size, buf + 2, len - 2) != TINF_OK) { ff_dprintf(ctx, "png: failed to uncompress IDAT data\n"); ctx->allocator.ff_free(uncompressed_data); @@ -436,3 +436,6 @@ ff_result ff_png_trans_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx return FF_RESULT_WARN_NO_IMPL; } + + +// TODO: Add ff_close_png
\ No newline at end of file |
