mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Add wuffs_gif__quirk_ignore_too_much_pixel_data
This commit is contained in:
1 parent
a1f777b16e
commit
24a2f12c30
3 files changed
+32
-8
No files matched your search
@@ -10993,7 +10993,8 @@ wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
||||
label_0_continue:;
|
||||
while (v_src_ri < ((uint64_t)(a_src.len))) {
|
||||
v_src = wuffs_base__slice_u8__subslice_i(a_src, v_src_ri);
|
||||
if (self->private_impl.f_dst_y >= self->private_impl.f_frame_rect_y1) {
|
||||
if ((self->private_impl.f_dst_y >= self->private_impl.f_frame_rect_y1) &&
|
||||
!self->private_impl.f_quirk_enabled_ignore_too_much_pixel_data) {
|
||||
return wuffs_base__error__too_much_data;
|
||||
}
|
||||
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
|
||||
|
||||
@@ -977,7 +977,8 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
||||
while src_ri < args.src.length() {
|
||||
src = args.src[src_ri:]
|
||||
|
||||
if this.dst_y >= this.frame_rect_y1 {
|
||||
if (this.dst_y >= this.frame_rect_y1) and
|
||||
(not this.quirk_enabled_ignore_too_much_pixel_data) {
|
||||
return base."#too much data"
|
||||
}
|
||||
|
||||
|
||||
+28
-6
@@ -468,6 +468,7 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
}
|
||||
|
||||
const char* do_test_wuffs_gif_decode_expecting(wuffs_base__io_buffer src,
|
||||
uint32_t quirk,
|
||||
const char* want_status,
|
||||
bool want_dirty_rect_is_empty) {
|
||||
wuffs_gif__decoder dec;
|
||||
@@ -477,6 +478,9 @@ const char* do_test_wuffs_gif_decode_expecting(wuffs_base__io_buffer src,
|
||||
if (status) {
|
||||
RETURN_FAIL("initialize: \"%s\"", status);
|
||||
}
|
||||
if (quirk) {
|
||||
wuffs_gif__decoder__set_quirk_enabled(&dec, quirk, true);
|
||||
}
|
||||
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__io_reader src_reader = wuffs_base__io_buffer__reader(&src);
|
||||
@@ -1238,7 +1242,7 @@ const char* test_wuffs_gif_decode_missing_two_src_bytes() {
|
||||
src.meta.wi -= 2;
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
src, wuffs_base__suspension__short_read, false);
|
||||
src, 0, wuffs_base__suspension__short_read, false);
|
||||
}
|
||||
|
||||
const char* test_wuffs_gif_decode_multiple_loop_counts() {
|
||||
@@ -1322,7 +1326,7 @@ const char* test_wuffs_gif_decode_pixel_data_none() {
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
src, wuffs_base__error__not_enough_data, true);
|
||||
src, 0, wuffs_base__error__not_enough_data, true);
|
||||
}
|
||||
|
||||
const char* test_wuffs_gif_decode_pixel_data_not_enough() {
|
||||
@@ -1339,10 +1343,10 @@ const char* test_wuffs_gif_decode_pixel_data_not_enough() {
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
src, wuffs_base__error__not_enough_data, false);
|
||||
src, 0, wuffs_base__error__not_enough_data, false);
|
||||
}
|
||||
|
||||
const char* test_wuffs_gif_decode_pixel_data_too_much() {
|
||||
const char* test_wuffs_gif_decode_pixel_data_too_much_sans_quirk() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
@@ -1356,7 +1360,24 @@ const char* test_wuffs_gif_decode_pixel_data_too_much() {
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
src, wuffs_base__error__too_much_data, false);
|
||||
src, 0, wuffs_base__error__too_much_data, false);
|
||||
}
|
||||
|
||||
const char* test_wuffs_gif_decode_pixel_data_too_much_with_quirk() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
read_file(&src, "test/data/artificial/gif-pixel-data-too-much.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
src, wuffs_gif__quirk_ignore_too_much_pixel_data, NULL, false);
|
||||
}
|
||||
|
||||
const char* test_wuffs_gif_frame_dirty_rect() {
|
||||
@@ -2007,7 +2028,8 @@ proc tests[] = {
|
||||
test_wuffs_gif_decode_multiple_loop_counts, //
|
||||
test_wuffs_gif_decode_pixel_data_none, //
|
||||
test_wuffs_gif_decode_pixel_data_not_enough, //
|
||||
test_wuffs_gif_decode_pixel_data_too_much, //
|
||||
test_wuffs_gif_decode_pixel_data_too_much_sans_quirk, //
|
||||
test_wuffs_gif_decode_pixel_data_too_much_with_quirk, //
|
||||
test_wuffs_gif_frame_dirty_rect, //
|
||||
test_wuffs_gif_num_decoded_frame_configs, //
|
||||
test_wuffs_gif_num_decoded_frames, //
|
||||
|
||||
Reference in new issue
Block a user