Skip to content

Commit

Permalink
Simplified code as both values are 7 bit
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 23, 2022
1 parent 4638c4f commit 8d7cc1f
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/libImaging/TgaRleDecode.c
Expand Up @@ -42,15 +42,13 @@ ImagingTgaRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
return ptr - buf;
}

n = depth * ((ptr[0] & 0x7f) + 1);
if (ptr[0] & 0x80) {
/* Run (1 + pixelsize bytes) */

if (bytes < 1 + depth) {
break;
}

n = depth * ((ptr[0] & 0x7f) + 1);

if (state->x + n > state->bytes) {
state->errcode = IMAGING_CODEC_OVERRUN;
return -1;
Expand All @@ -67,11 +65,8 @@ ImagingTgaRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t

ptr += 1 + depth;
bytes -= 1 + depth;

} else {
/* Literal (1+n+1 bytes block) */
n = depth * (ptr[0] + 1);

if (bytes < 1 + n) {
break;
}
Expand Down

0 comments on commit 8d7cc1f

Please sign in to comment.