Skip to content

Commit 17d342b

Browse files
committed
Simplified code as both values are 7 bit
1 parent 14b9b59 commit 17d342b

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/libImaging/TgaRleDecode.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ ImagingTgaRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
4242
return ptr - buf;
4343
}
4444

45+
n = depth * ((ptr[0] & 0x7f) + 1);
4546
if (ptr[0] & 0x80) {
4647
/* Run (1 + pixelsize bytes) */
47-
4848
if (bytes < 1 + depth) {
4949
break;
5050
}
5151

52-
n = depth * ((ptr[0] & 0x7f) + 1);
53-
5452
if (state->x + n > state->bytes) {
5553
state->errcode = IMAGING_CODEC_OVERRUN;
5654
return -1;
@@ -67,11 +65,8 @@ ImagingTgaRleDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
6765

6866
ptr += 1 + depth;
6967
bytes -= 1 + depth;
70-
7168
} else {
7269
/* Literal (1+n+1 bytes block) */
73-
n = depth * (ptr[0] + 1);
74-
7570
if (bytes < 1 + n) {
7671
break;
7772
}

0 commit comments

Comments
 (0)