wordpad: Avoid an out-of-bounds array access in registry_set_filelist.

Gerald Pfeifer gerald at pfeifer.com
Sat Dec 27 02:57:41 CST 2014


Check whether i is within bounds before using it to access the
array instead of the other way around.

Gerald
---
 programs/wordpad/registry.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/programs/wordpad/registry.c b/programs/wordpad/registry.c
index 5b570e7..22b5c06 100644
--- a/programs/wordpad/registry.c
+++ b/programs/wordpad/registry.c
@@ -318,7 +318,7 @@ void registry_set_filelist(LPCWSTR newFile, HWND hMainWnd)
                 pFiles[0] = newFile;
             }
 
-            for(i = 0; pFiles[i] && i < FILELIST_ENTRIES; i++)
+            for(i = 0; i < FILELIST_ENTRIES && pFiles[i]; i++)
             {
                 wsprintfW(buffer, var_file, i+1);
                 RegSetValueExW(hKey, (LPWSTR)&buffer, 0, REG_SZ, (const BYTE*)pFiles[i],
-- 
2.2.1



More information about the wine-patches mailing list