Skip to content

Commit 98b8129

Browse files
Herongguang (Stephen)mdroth
Herongguang (Stephen)
authored andcommitted
vnc-enc-tight: fix off-by-one bug
In tight_encode_indexed_rect32, buf(or src)’s size is count. In for loop, the logic is supposed to be that i is an index into src, i should be incremented when incrementing src. This is broken when src is incremented but i is not before while loop, resulting in off-by-one bug in while loop. Signed-off-by: He Rongguang <[email protected]> Message-id: [email protected] Signed-off-by: Gerd Hoffmann <[email protected]> (cherry picked from commit 3f7e51b) Signed-off-by: Michael Roth <[email protected]>
1 parent 8ef7abe commit 98b8129

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ui/vnc-enc-tight.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,10 @@ static int tight_fill_palette(VncState *vs, int x, int y,
461461
\
462462
src = (uint##bpp##_t *) buf; \
463463
\
464-
for (i = 0; i < count; i++) { \
464+
for (i = 0; i < count; ) { \
465465
\
466466
rgb = *src++; \
467+
i++; \
467468
rep = 0; \
468469
while (i < count && *src == rgb) { \
469470
rep++, src++, i++; \

0 commit comments

Comments
 (0)