CVS: winex/dlls/winmm mmsystem.c,1.16,1.17

[email protected] 1 Aug 2007 12:30:08 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/winmm mmsystem.c,1.16,1.17Update of /var/lib/cvsd/cvsroot/winex/dlls/winmm
In directory agravaine:/tmp/cvs-serv28948/dlls/winmm

Modified Files:
	mmsystem.c 
Log Message:

- fixed GetModuleFileNameA() to properly return a truncated filename error code.  GetModuleFileNameW() just calls GetModuleFileNameA(), so its error codes should be updated as well.
- fixed all the calls to GetModuleFileNameA/W() to check for small buffer and bad module errors.  Currently small buffer errors are just reported and are allowed to proceed with either an empty string or truncated string for the filename.  In the case of an error retrieving the module filename (error == 0), the calling function reports the error and returns immediately.


Index: mmsystem.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/winmm/mmsystem.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mmsystem.c	28 Mar 2007 21:00:03 -0000	1.16
+++ mmsystem.c	1 Aug 2007 12:30:06 -0000	1.17
@@ -286,6 +286,7 @@
     HMMIO  	hmmio;
     HKEY        hRegSnd, hRegApp, hScheme, hSnd;
     DWORD       err, type, count;
+    DWORD       err2;
 
     static  WCHAR       wszSounds[] = {'S','o','u','n','d','s',0};
     static  WCHAR       wszDefault[] = {'D','e','f','a','u','l','t',0};
@@ -316,7 +317,8 @@
     if (uFlags & SND_APPLICATION)
     {
         err = 1; /* error */
-        if (GetModuleFileNameW(0, str, sizeof(str)/sizeof(str[0])))
+        err2 = GetModuleFileNameW(0, str, sizeof(str)/sizeof(str[0]));
+        if (err2 != 0 && err2 != sizeof(str)/sizeof(str[0]))
         {
             for (ptr = str + lstrlenW(str) - 1; ptr >= str; ptr--)
             {
@@ -328,6 +330,9 @@
                 }
             }
         }
+
+        else
+            ERR("the module filename could not be retrieved (reason: '%s')\n", err2 == 0 ? "bad module" : "buffer too small");
     }
     else
     {