From db000ee3e8ecb174133a3607325af0d49d084332 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Sun, 18 Apr 1999 13:18:42 +0000
Subject: [PATCH] Fixed toolhelp routines usage in GetModuleFromPath (reported
 by Bertho Stultiens).

---
 loader/ne/module.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/loader/ne/module.c b/loader/ne/module.c
index 73a81a10ac7..0481f2127fd 100644
--- a/loader/ne/module.c
+++ b/loader/ne/module.c
@@ -1442,8 +1442,9 @@ static HMODULE16 GetModuleFromPath(LPCSTR name)
 	{
 check_path:
 		lookforit.dwSize=sizeof(MODULEENTRY);
-		for(ModuleFirst16(&lookforit); ModuleNext16(&lookforit); )
-		{
+		if (!ModuleFirst16(&lookforit)) return 0;
+                do
+                {
 			pModule = NE_GetPtr(lookforit.hModule);
 			if(!pModule) 
 				break;
@@ -1459,7 +1460,7 @@ check_path:
 					break;
 				}
 			}
-		}
+                } while (ModuleNext16(&lookforit));
 	}
 
 	if(TRACE_ON(module) && hmod)
-- 
GitLab