From 4d652b7855d1f852fd81fcffe7dabf9c685c9a0b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 30 Jun 2005 11:42:56 +0000 Subject: Fix crashes with pixel readback when using the optimized assembly functions. Pixel count can be negative (this could be fixed elsewhere), so adapt the functions to work with such inputs correctly (same behaviour as non-optimized functions). Bugzilla #2317 Submitted by idr --- src/mesa/x86/read_rgba_span_x86.S | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/mesa/x86') diff --git a/src/mesa/x86/read_rgba_span_x86.S b/src/mesa/x86/read_rgba_span_x86.S index 7315826b4d..6b8036e5b8 100644 --- a/src/mesa/x86/read_rgba_span_x86.S +++ b/src/mesa/x86/read_rgba_span_x86.S @@ -92,7 +92,7 @@ _generic_read_RGBA_span_BGRA8888_REV_MMX: movl 12(%esp), %ecx /* destination pointer */ testl %edx, %edx - je .L20 /* Bail if there's nothing to do. */ + jle .L20 /* Bail if there's nothing to do. */ movl %ebx, %eax @@ -189,6 +189,9 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE: movl 24(%esp), %edx /* number of pixels to copy */ movl 20(%esp), %ecx /* destination pointer */ + testl %edx, %edx + jle .L35 /* Bail if there's nothing to do. */ + movl %esp, %ebp subl $16, %esp andl $0xfffffff0, %esp @@ -348,6 +351,9 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE2: movl %ebx, %eax movl %edx, %esi + testl %edx, %edx + jle .L46 /* Bail if there's nothing to do. */ + /* If the source pointer isn't a multiple of 16 we have to process * a few pixels the "slow" way to get the address aligned for * the SSE fetch intsructions. @@ -528,7 +534,8 @@ _generic_read_RGBA_span_RGB565_MMX: movq prescale, %mm6 movq scale, %mm7 - shrl $2, %ecx + sarl $2, %ecx + jle .L01 /* Bail early if the count is negative. */ jmp .L02 .L03: -- cgit v1.2.3