Skip to content

Commit

Permalink
gif: fix detection of truncated files in GetCode (bug #4802)
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Sep 12, 2019
1 parent bb819ae commit f5eef6b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion IMG_gif.c
Expand Up @@ -405,8 +405,12 @@ GetCode(SDL_RWops *src, int code_size, int flag, State_t * state)
state->buf[0] = state->buf[state->last_byte - 2];
state->buf[1] = state->buf[state->last_byte - 1];

if ((count = GetDataBlock(src, &state->buf[2], state)) <= 0)
if ((ret = GetDataBlock(src, &state->buf[2], state)) > 0)
count = (unsigned char) ret;
else {
count = 0;
state->done = TRUE;
}

state->last_byte = 2 + count;
state->curbit = (state->curbit - state->lastbit) + 16;
Expand Down

0 comments on commit f5eef6b

Please sign in to comment.