Gabriel Ivăncescu : mshtml: Handle empty strings in heap_strndupWtoU.
Alexandre Julliard
julliard at winehq.org
Fri May 27 16:35:30 CDT 2022
Module: wine
Branch: master
Commit: 239b5726d412958a5df42314574807f7c723d910
URL: https://source.winehq.org/git/wine.git/?a=commit;h=239b5726d412958a5df42314574807f7c723d910
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Thu May 26 19:54:26 2022 +0300
mshtml: Handle empty strings in heap_strndupWtoU.
The HTTP response header status text can be empty, so
process_response_status_text would erroneously return E_OUTOFMEMORY.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/mshtml_private.h | 6 +++---
dlls/wininet/tests/http.c | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index ad1fca091fa..0a7c3a2556e 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -1392,11 +1392,11 @@ static inline char *heap_strndupWtoU(LPCWSTR str, unsigned len)
char *ret = NULL;
DWORD size;
- if(str && len) {
- size = WideCharToMultiByte(CP_UTF8, 0, str, len, NULL, 0, NULL, NULL);
+ if(str) {
+ size = len ? WideCharToMultiByte(CP_UTF8, 0, str, len, NULL, 0, NULL, NULL) : 0;
ret = heap_alloc(size + 1);
if(ret) {
- WideCharToMultiByte(CP_UTF8, 0, str, len, ret, size, NULL, NULL);
+ if(len) WideCharToMultiByte(CP_UTF8, 0, str, len, ret, size, NULL, NULL);
ret[size] = '\0';
}
}
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index ec576ae81e2..bc1b829fca2 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -4526,6 +4526,13 @@ static const http_status_test_t http_status_tests[] = {
200,
""
},
+ {
+ "HTTP/1.1 200 \r\n"
+ "Content-Length: 1\r\n"
+ "\r\nx",
+ 200,
+ ""
+ },
{
"HTTP/1.1 410 \r\n"
"Content-Length: 1\r\n"
More information about the wine-cvs
mailing list