diff options
| -rw-r--r-- | include/tinyff/image/bmp.h | 2 | ||||
| -rw-r--r-- | src/format/image/bmp.c | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/include/tinyff/image/bmp.h b/include/tinyff/image/bmp.h index c63f974..bfafcdc 100644 --- a/include/tinyff/image/bmp.h +++ b/include/tinyff/image/bmp.h @@ -45,7 +45,7 @@ typedef struct { typedef ff_result (*ff_bmp_section_handler_ptr)(uint8_t *buf, size_t len, ff_bmp_ctx* ctx); ff_result ff_bmp_isvalid(ff_stream *stream); -ff_result ff_open_bmp(ff_stream *stream, ff_bmp_ctx **out_ctx); +ff_result ff_open_bmp(ff_stream *stream, ff_bmp_ctx **out_ctx, ff_flag require_valid); #endif // BMP_H_
\ No newline at end of file diff --git a/src/format/image/bmp.c b/src/format/image/bmp.c index ed358df..7dfaa76 100644 --- a/src/format/image/bmp.c +++ b/src/format/image/bmp.c @@ -25,7 +25,7 @@ ff_result ff_bmp_isvalid(ff_stream* stream) return FF_RESULT_OK; } -ff_result ff_open_bmp(ff_stream *stream, ff_bmp_ctx **out_ctx) +ff_result ff_open_bmp(ff_stream *stream, ff_bmp_ctx **out_ctx, ff_flag require_valid) { ff_bmp_ctx *ctx = malloc(sizeof(ff_bmp_ctx)); @@ -45,11 +45,13 @@ ff_result ff_open_bmp(ff_stream *stream, ff_bmp_ctx **out_ctx) ff_dprintf("bmp: stream read successfully\n"); - ff_result res = ff_bmp_isvalid(ctx->raw); - if (res != FF_RESULT_OK) { - ff_dprintf("bmp: validation failed (%d)\n", res); - free(ctx); - return res; + if (require_valid) { + ff_result res = ff_bmp_isvalid(ctx->raw); + if (res != FF_RESULT_OK) { + ff_dprintf("bmp: validation failed (%d)\n", res); + free(ctx); + return res; + } } ff_dprintf("bmp: validation passed\n"); |
