dwrite: Fix possible NULL pointer access in heap_strdup*

André Hentschel nerv at dawncrow.de
Sat Nov 17 15:52:26 CST 2012


we already do that (ieframe,vbscript,wininet,.. are good examples), but not consistent all over the place
---
 dlls/dwrite/dwrite_private.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 54ae0dc..0c2698e 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -47,7 +47,8 @@ static inline LPWSTR heap_strdupW(const WCHAR *str)
 
         size = (strlenW(str)+1)*sizeof(WCHAR);
         ret = heap_alloc(size);
-        memcpy(ret, str, size);
+        if(ret)
+            memcpy(ret, str, size);
     }
 
     return ret;
@@ -60,8 +61,11 @@ static inline LPWSTR heap_strdupnW(const WCHAR *str, UINT32 len)
     if (len)
     {
         ret = heap_alloc((len+1)*sizeof(WCHAR));
-        memcpy(ret, str, len*sizeof(WCHAR));
-        ret[len] = 0;
+        if(ret)
+        {
+            memcpy(ret, str, len*sizeof(WCHAR));
+            ret[len] = 0;
+        }
     }
 
     return ret;
-- 
1.8.0



-- 

Best Regards, André Hentschel


More information about the wine-patches mailing list