giflib: avoid redundant loop counter
A library and utilities for processing GIFs
Brought to you by:
abadger1999,
esr
DGifDecompressLine uses j as while loop iteration counter to detect infinite loops. StackPtr can be used instead, and it can better protect against Stack[] overflow.
Alternatively, while condition can have CrntPrefix > Prefix[CrntPrefix] (similar can be used in DGifGetPrefixChar), which is true for correctly created Prefix[] table and is sufficient to guard against Stack[] overflow. Such check may reject inputs that are somewhat corrupted, but do not create Prefix[] loop. There are other checks that should avoid CrntPrefix <= Prefix[CrntPrefix] situation from occuring, I've not looked if it's possible to bypass them to get to such somwhat corrupted state.
Use StackPtr as loop counter