From 07c315c504da5aabdf4b32c331aae5b716a91135 Mon Sep 17 00:00:00 2001 From: Kamil Hornicek Date: Fri, 16 May 2014 15:52:15 +0000 Subject: [PATCH] [OPENGL32] - don't try to free an invalid address svn path=/trunk/; revision=63314 --- reactos/dll/opengl/opengl32/wgl_font.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/reactos/dll/opengl/opengl32/wgl_font.c b/reactos/dll/opengl/opengl32/wgl_font.c index 95d01cff8f4..9640d41f411 100644 --- a/reactos/dll/opengl/opengl32/wgl_font.c +++ b/reactos/dll/opengl/opengl32/wgl_font.c @@ -347,7 +347,7 @@ static BOOL wglUseFontOutlines_common(HDC hdc, BYTE *buf; TTPOLYGONHEADER *pph; TTPOLYCURVE *ppc; - GLdouble *vertices = NULL; + GLdouble *vertices = NULL, *vertices_temp = NULL; int vertex_total = -1; if(unicode) @@ -360,6 +360,9 @@ static BOOL wglUseFontOutlines_common(HDC hdc, buf = HeapAlloc(GetProcessHeap(), 0, needed); + if(!buf) + goto error; + if(unicode) GetGlyphOutlineW(hdc, glyph, GGO_NATIVE, &gm, needed, buf, &identity); else @@ -393,7 +396,7 @@ static BOOL wglUseFontOutlines_common(HDC hdc, while(!vertices) { if(vertex_total != -1) - vertices = HeapAlloc(GetProcessHeap(), 0, vertex_total * 3 * sizeof(GLdouble)); + vertices_temp = vertices = HeapAlloc(GetProcessHeap(), 0, vertex_total * 3 * sizeof(GLdouble)); vertex_total = 0; pph = (TTPOLYGONHEADER*)buf; @@ -521,8 +524,11 @@ error_in_list: pgluTessEndPolygon(tess); funcs->Translated((GLdouble)gm.gmCellIncX / em_size, (GLdouble)gm.gmCellIncY / em_size, 0.0); funcs->EndList(); + HeapFree(GetProcessHeap(), 0, buf); - HeapFree(GetProcessHeap(), 0, vertices); + + if(vertices_temp) + HeapFree(GetProcessHeap(), 0, vertices_temp); } error: