From e9bfe83683266edcc2917e3d151254aefd4b070d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= Date: Sat, 17 Nov 2012 22:52:32 +0100 Subject: [PATCH] mshtml: Fix possible NULL pointer access in heap_str*. --- dlls/mshtml/mshtml_private.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 6c7662e4938..f9c05f06917 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -1033,7 +1033,8 @@ static inline LPWSTR heap_strdupW(LPCWSTR str) size = (strlenW(str)+1)*sizeof(WCHAR); ret = heap_alloc(size); - memcpy(ret, str, size); + if(ret) + memcpy(ret, str, size); } return ret; @@ -1045,8 +1046,11 @@ static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len) if(str) { 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; @@ -1061,7 +1065,8 @@ static inline char *heap_strdupA(const char *str) size = strlen(str)+1; ret = heap_alloc(size); - memcpy(ret, str, size); + if(ret) + memcpy(ret, str, size); } return ret; @@ -1076,7 +1081,8 @@ static inline WCHAR *heap_strdupAtoW(const char *str) len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); ret = heap_alloc(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + if(ret) + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); } return ret; @@ -1089,7 +1095,8 @@ static inline char *heap_strdupWtoA(LPCWSTR str) if(str) { DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); ret = heap_alloc(size); - WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL); + if(ret) + WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL); } return ret;