[SHELL32]check for NULL pointer in CShellLink::SetDescription. patch by Joachim Henze...
authorChristoph von Wittich <christoph_vw@reactos.org>
Thu, 28 Jul 2016 15:12:23 +0000 (15:12 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Thu, 28 Jul 2016 15:12:23 +0000 (15:12 +0000)
svn path=/trunk/; revision=72033

reactos/dll/win32/shell32/CShellLink.cpp

index e639f62..8b5bb30 100644 (file)
@@ -1332,12 +1332,17 @@ HRESULT WINAPI CShellLink::SetDescription(LPCWSTR pszName)
     TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
 
     HeapFree(GetProcessHeap(), 0, sDescription);
-    sDescription = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
-                                     (wcslen(pszName) + 1) * sizeof(WCHAR));
-    if (!sDescription)
-        return E_OUTOFMEMORY;
+    if (pszName)
+    {
+        sDescription = (LPWSTR)HeapAlloc(GetProcessHeap(), 0,
+                                         (wcslen(pszName) + 1) * sizeof(WCHAR));
+        if (!sDescription)
+            return E_OUTOFMEMORY;
 
-    wcscpy(sDescription, pszName);
+        wcscpy(sDescription, pszName);
+    }
+    else
+        sDescription = NULL;    
     bDirty = TRUE;
 
     return S_OK;