diff --git a/patterns/ani.hexpat b/patterns/ani.hexpat index f23ff75..5709032 100644 --- a/patterns/ani.hexpat +++ b/patterns/ani.hexpat @@ -36,7 +36,12 @@ struct RiffChunk { u32 size; if (signature == "RIFF" || signature == "LIST") { char type[4]; - RiffChunk chunks[while($ - addressof(type) < size)]; + + // Compatible with error size defined in ani files + u32 remain = sizeof($) - addressof(type); + u32 marked = size > remain ? remain : size; + + RiffChunk chunks[while($ - addressof(type) < marked)]; } else if (signature[0] == 'I' && parent.type == "INFO") { char info[size]; } else if (signature == "anih") { diff --git a/tests/patterns/test_data/ani.compatibility.hexpat.ani b/tests/patterns/test_data/ani.compatibility.hexpat.ani new file mode 100644 index 0000000..abc6ed8 Binary files /dev/null and b/tests/patterns/test_data/ani.compatibility.hexpat.ani differ