Module: wine Branch: master Commit: 412b36e45a7d086747b6ef42b9b9b0e432ac4d77 URL: https://source.winehq.org/git/wine.git/?a=commit;h=412b36e45a7d086747b6ef42b...
Author: Esme Povirk esme@codeweavers.com Date: Sat Dec 11 14:04:26 2021 -0600
dwrite: Avoid calling memcpy with NULL source.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52187 Signed-off-by: Esme Povirk esme@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dwrite/analyzer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c index 7112ca71932..8ecfad5f3a5 100644 --- a/dlls/dwrite/analyzer.c +++ b/dlls/dwrite/analyzer.c @@ -868,7 +868,8 @@ static HRESULT get_text_source_ptr(IDWriteTextAnalysisSource *source, UINT32 pos *buff = malloc(length * sizeof(WCHAR)); if (!*buff) return E_OUTOFMEMORY; - memcpy(*buff, *text, len*sizeof(WCHAR)); + if (*text) + memcpy(*buff, *text, len*sizeof(WCHAR)); read = len;
while (read < length && *text) { @@ -880,6 +881,8 @@ static HRESULT get_text_source_ptr(IDWriteTextAnalysisSource *source, UINT32 pos free(*buff); return hr; } + if (!*text) + break; memcpy(*buff + read, *text, min(len, length-read)*sizeof(WCHAR)); read += len; } @@ -1009,7 +1012,8 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeLineBreakpoints(IDWriteTextAnaly
if (!(buff = calloc(length, sizeof(*buff)))) return E_OUTOFMEMORY; - memcpy(buff, text, len*sizeof(WCHAR)); + if (text) + memcpy(buff, text, len*sizeof(WCHAR)); read = len;
while (read < length && text) { @@ -1018,6 +1022,8 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeLineBreakpoints(IDWriteTextAnaly hr = IDWriteTextAnalysisSource_GetTextAtPosition(source, read, &text, &len); if (FAILED(hr)) goto done; + if (!text) + break; memcpy(&buff[read], text, min(len, length-read)*sizeof(WCHAR)); read += len; }