Skip to content

Commit f610712

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Better fix for #68601 for perf https://bitbucket.org/libgd/gd-libgd/commits/81e9a993f2893d651d225646378e3fd1b7465467
2 parents 4d21ad3 + f382fbf commit f610712

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/gd/libgd/gd_gif_in.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,14 @@ GetCode_(gdIOCtx *fd, CODE_STATIC_DATA *scd, int code_size, int flag, int *ZeroD
400400
scd->lastbit = (2+count)*8 ;
401401
}
402402

403-
ret = 0;
404-
for (i = scd->curbit, j = 0; j < code_size; ++i, ++j)
405-
if (i < CSD_BUF_SIZE * 8) {
403+
if ((scd->curbit + code_size - 1) >= (CSD_BUF_SIZE * 8)) {
404+
ret = -1;
405+
} else {
406+
ret = 0;
407+
for (i = scd->curbit, j = 0; j < code_size; ++i, ++j) {
406408
ret |= ((scd->buf[i / 8] & (1 << (i % 8))) != 0) << j;
407-
} else {
408-
ret = -1;
409-
break;
410409
}
410+
}
411411

412412
scd->curbit += code_size;
413413
return ret;

0 commit comments

Comments
 (0)