Alexander Nicolaysen Sørnes : regedit: Don't try to convert NULL pointers.

Alexandre Julliard julliard at winehq.org
Tue Sep 2 08:33:04 CDT 2008


Module: wine
Branch: master
Commit: 7aa56d249a4faf7d4ded68a817889979977ad366
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7aa56d249a4faf7d4ded68a817889979977ad366

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Sat Aug 30 01:23:09 2008 +0200

regedit: Don't try to convert NULL pointers.

---

 programs/regedit/regproc.c |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index eb724be..a085ae4 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -70,13 +70,17 @@ if (!(p)) \
  */
 WCHAR* GetWideString(const char* strA)
 {
-    WCHAR* strW = NULL;
-    int len = MultiByteToWideChar(CP_ACP, 0, strA, -1, NULL, 0);
+    if(strA)
+    {
+        WCHAR* strW = NULL;
+        int len = MultiByteToWideChar(CP_ACP, 0, strA, -1, NULL, 0);
 
-    strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
-    CHECK_ENOUGH_MEMORY(strW);
-    MultiByteToWideChar(CP_ACP, 0, strA, -1, strW, len);
-    return strW;
+        strW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        CHECK_ENOUGH_MEMORY(strW);
+        MultiByteToWideChar(CP_ACP, 0, strA, -1, strW, len);
+        return strW;
+    }
+    return NULL;
 }
 
 /******************************************************************************
@@ -85,13 +89,17 @@ WCHAR* GetWideString(const char* strA)
  */
 char* GetMultiByteString(const WCHAR* strW)
 {
-    char* strA = NULL;
-    int len = WideCharToMultiByte(CP_ACP, 0, strW, -1, NULL, 0, NULL, NULL);
+    if(strW)
+    {
+        char* strA = NULL;
+        int len = WideCharToMultiByte(CP_ACP, 0, strW, -1, NULL, 0, NULL, NULL);
 
-    strA = HeapAlloc(GetProcessHeap(), 0, len);
-    CHECK_ENOUGH_MEMORY(strA);
-    WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, len, NULL, NULL);
-    return strA;
+        strA = HeapAlloc(GetProcessHeap(), 0, len);
+        CHECK_ENOUGH_MEMORY(strA);
+        WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, len, NULL, NULL);
+        return strA;
+    }
+    return NULL;
 }
 
 /******************************************************************************




More information about the wine-cvs mailing list