[PATCH] winspool: Move parameter-checks for EnumMonitorsW to localspl

Detlef Riekenberg wine.dev at web.de
Thu Jul 10 16:42:55 CDT 2008


---
 dlls/localspl/localspl_main.c |   10 ++++++----
 dlls/winspool.drv/info.c      |    8 +-------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/dlls/localspl/localspl_main.c b/dlls/localspl/localspl_main.c
index b27ae7d..cf208f0 100644
--- a/dlls/localspl/localspl_main.c
+++ b/dlls/localspl/localspl_main.c
@@ -736,6 +736,12 @@ BOOL WINAPI fpEnumMonitors(LPWSTR pName, DWORD Level, LPBYTE pMonitors, DWORD cb
         goto em_cleanup;
     }
 
+    if (!Level || (Level > 2)) {
+        WARN("level (%d) is ignored in win9x\n", Level);
+        SetLastError(ERROR_INVALID_LEVEL);
+        return FALSE;
+    }
+
     /* Scan all Monitor-Keys */
     numentries = 0;
     needed = get_local_monitors(Level, NULL, 0, &numentries);
@@ -745,10 +751,6 @@ BOOL WINAPI fpEnumMonitors(LPWSTR pName, DWORD Level, LPBYTE pMonitors, DWORD cb
         SetLastError(ERROR_INSUFFICIENT_BUFFER);
         goto em_cleanup;
     }
-    else if (!pMonitors || !pcReturned) {
-        SetLastError(RPC_X_NULL_REF_POINTER);
-        goto em_cleanup;
-    }
 
     /* fill the Buffer with the Monitor-Keys */
     needed = get_local_monitors(Level, pMonitors, cbBuf, &numentries);
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index b7b290f..3717936 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -7246,13 +7246,7 @@ BOOL WINAPI EnumMonitorsW(LPWSTR pName, DWORD Level, LPBYTE pMonitors,
 
     if ((backend == NULL)  && !load_backend()) return FALSE;
 
-    /* Level is not checked in win9x */
-    if (!Level || (Level > 2)) {
-        WARN("level (%d) is ignored in win9x\n", Level);
-        SetLastError(ERROR_INVALID_LEVEL);
-        return FALSE;
-    }
-    if (!pcbNeeded) {
+    if (!pcbNeeded || !pcReturned || (!pMonitors && (cbBuf > 0))) {
         SetLastError(RPC_X_NULL_REF_POINTER);
         return FALSE;
     }
-- 
1.5.4.3


--=-YVwKYCrab5WXhwtEbIE1--




More information about the wine-patches mailing list