[PATCH] winefile: check index before buffer overread (Coverity)

Marcus Meissner marcus at jet.franken.de
Sat Oct 13 09:58:05 CDT 2012


Hi,

check i for loop bound before dereferencing array.

Aligned if (x < y) spacing in the function.

Ciao, Marcus
---
 programs/winefile/winefile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/programs/winefile/winefile.c b/programs/winefile/winefile.c
index 366aa9c..23388c1 100644
--- a/programs/winefile/winefile.c
+++ b/programs/winefile/winefile.c
@@ -3163,7 +3163,7 @@ static void set_header(Pane* pane)
 	item.mask = HDI_WIDTH;
 	item.cxy = 0;
 
-	for(; x+pane->widths[i]<scroll_pos && i<COLUMNS; i++) {
+	for(; (i < COLUMNS) && (x+pane->widths[i] < scroll_pos); i++) {
 		x += pane->widths[i];
 		SendMessageW(pane->hwndHeader, HDM_SETITEMW, i, (LPARAM)&item);
 	}
@@ -3173,7 +3173,7 @@ static void set_header(Pane* pane)
 		item.cxy = x - scroll_pos;
 		SendMessageW(pane->hwndHeader, HDM_SETITEMW, i++, (LPARAM)&item);
 
-		for(; i<COLUMNS; i++) {
+		for(; i < COLUMNS; i++) {
 			item.cxy = pane->widths[i];
 			x += pane->widths[i];
 			SendMessageW(pane->hwndHeader, HDM_SETITEMW, i, (LPARAM)&item);
-- 
1.7.3.4




More information about the wine-patches mailing list