Author: mjansen
Date: Wed Jul 13 18:02:16 2016
New Revision: 71931

URL: http://svn.reactos.org/svn/reactos?rev=71931&view=rev
Log:
[APPHELP] Dereference after null check (default_dir). CID 1363509

Modified:
    trunk/reactos/dll/appcompat/apphelp/sdbapi.c

Modified: trunk/reactos/dll/appcompat/apphelp/sdbapi.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/sdbapi.c?rev=71931&r1=71930&r2=71931&view=diff
==============================================================================
--- trunk/reactos/dll/appcompat/apphelp/sdbapi.c        [iso-8859-1] (original)
+++ trunk/reactos/dll/appcompat/apphelp/sdbapi.c        [iso-8859-1] Wed Jul 13 
18:02:16 2016
@@ -472,30 +472,35 @@
     static WCHAR* default_dir = NULL;
     static CONST WCHAR szAppPatch[] = {'\\','A','p','p','P','a','t','c','h',0};
 
-    if(!default_dir)
+    /* In case function fails, path holds empty string */
+    if (size > 0)
+        *path = 0;
+
+    if (!default_dir)
     {
         WCHAR* tmp = NULL;
         UINT len = GetSystemWindowsDirectoryW(NULL, 0) + lstrlenW(szAppPatch);
         tmp = SdbAlloc((len + 1)* sizeof(WCHAR));
-        if(tmp)
+        if (tmp)
         {
             UINT r = GetSystemWindowsDirectoryW(tmp, len+1);
             if (r && r < len)
             {
                 if (SUCCEEDED(StringCchCatW(tmp, len+1, szAppPatch)))
                 {
-                    if(InterlockedCompareExchangePointer((void**)&default_dir, 
tmp, NULL) == NULL)
+                    if 
(InterlockedCompareExchangePointer((void**)&default_dir, tmp, NULL) == NULL)
                         tmp = NULL;
                 }
             }
             if (tmp)
                 SdbFree(tmp);
         }
-    }
-
-    /* In case function fails, path holds empty string */
-    if (size > 0)
-        *path = 0;
+        if (!default_dir)
+        {
+            SHIM_ERR("Unable to obtain default AppPatch directory\n");
+            return FALSE;
+        }
+    }
 
     if (!db)
     {


Reply via email to