[PATCH] gdi32: Avoid awkward cast in GetGlyphOutlineA (Coverity)
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- CID 713109 (#1 of 1): Reliance on integer endianness (INCOMPATIBLE_CAST) incompatible_cast: Pointer &uChar points to an object whose effective type is unsigned int (32 bits, unsigned) but is dereferenced as a narrower unsigned short (16 bits, unsigned). This may lead to unexpected results depending on machine endianness. dlls/gdi32/font.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 17b160d2dc..3347c9208c 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -2817,6 +2817,8 @@ DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPVOID lpBuffer, const MAT2 *lpmat2 ) { + WCHAR wChar; + if (!lpmat2) return GDI_ERROR; if(!(fuFormat & GGO_GLYPH_INDEX)) { @@ -2833,8 +2835,9 @@ DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat, len = 1; mbchs[0] = (uChar & 0xff); } - uChar = 0; - MultiByteToWideChar(cp, 0, mbchs, len, (LPWSTR)&uChar, 1); + wChar = 0; + MultiByteToWideChar(cp, 0, mbchs, len, &wChar, 1); + uChar = wChar; } return GetGlyphOutlineW(hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, -- 2.17.0
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- CID 716634 (#1 of 1): Resource leak (RESOURCE_LEAK) leaked_storage: Variable pStrokes going out of scope leaks the storage it points to. dlls/gdi32/path.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c index 41cab60515..ceb8d29977 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -1749,6 +1749,8 @@ static struct gdi_path *PATH_WidenPath(DC *dc) break; default: ERR("Got path flag %c\n", flat_path->flags[i]); + HeapFree(GetProcessHeap(), 0, pStrokes); + free_gdi_path(flat_path); return NULL; } } -- 2.17.0
On Thu, May 31, 2018 at 11:03:36PM -0600, Alex Henrie wrote:
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- CID 716634 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable pStrokes going out of scope leaks the storage it points to.
dlls/gdi32/path.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c index 41cab60515..ceb8d29977 100644 --- a/dlls/gdi32/path.c +++ b/dlls/gdi32/path.c @@ -1749,6 +1749,8 @@ static struct gdi_path *PATH_WidenPath(DC *dc) break; default: ERR("Got path flag %c\n", flat_path->flags[i]); + HeapFree(GetProcessHeap(), 0, pStrokes); + free_gdi_path(flat_path); return NULL; } }
Not that this really matters, but since you're doing it, we should also free the paths stored in the pStrokes array. Huw.
participants (2)
-
Alex Henrie -
Huw Davies