msvcrt: move error condition before memory allocation (found by Smatch).
Lionel Debroux
lionel_debroux at yahoo.fr
Mon Sep 24 06:32:43 CDT 2007
---
dlls/msvcrt/dir.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c
index 06013c6..bd42afe 100644
--- a/dlls/msvcrt/dir.c
+++ b/dlls/msvcrt/dir.c
@@ -750,6 +750,12 @@ MSVCRT_wchar_t * CDECL _wfullpath(MSVCRT_wchar_t * absPath, const MSVCRT_wchar_t
if (!relPath || !*relPath)
return _wgetcwd(absPath, size);
+ if (size < 4)
+ {
+ *MSVCRT__errno() = MSVCRT_ERANGE;
+ return NULL;
+ }
+
if (absPath == NULL)
{
buffer = MSVCRT_malloc(MAX_PATH * sizeof(WCHAR));
@@ -759,12 +765,6 @@ MSVCRT_wchar_t * CDECL _wfullpath(MSVCRT_wchar_t * absPath, const MSVCRT_wchar_t
else
buffer = absPath;
- if (size < 4)
- {
- *MSVCRT__errno() = MSVCRT_ERANGE;
- return NULL;
- }
-
TRACE(":resolving relative path %s\n",debugstr_w(relPath));
rc = GetFullPathNameW(relPath,size,buffer,&lastpart);
--
1.5.3.1
--------------030509080301000900040905--
More information about the wine-patches
mailing list