This should have been done in c2e5749443 (Fix crash when reading truncated GIF image, 2023-07-02), but was forgotten there -- so do it now, and add a comment reminding not to forget it the next time. See #23409.
c2e5749443