[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    3/12 regedit: Don't try to convert NULL pointers
From:       Alexander Nicolaysen =?iso-8859-1?q?S=F8rnes?= <alex () thehandofagony ! com>
Date:       2008-08-31 22:59:15
Message-ID: 200809010059.16046.alex () thehandofagony ! com
[Download RAW message or body]

3/12 regedit: Don't try to convert NULL pointers


Alexander N. S=F8rnes

["0003-regedit-Don-t-try-to-convert-NULL-strings.patch" (text/x-diff)]

From f0fdd810e0901f8ef296290119ce7024debda35f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= <alex@thehandofagony.com>
Date: Sat, 30 Aug 2008 01:23:09 +0200
Subject: [PATCH] regedit: Don't try to convert NULL strings

---
 programs/regedit/regproc.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 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;
 }
 
 /******************************************************************************
-- 
1.5.3.7





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic