Module: wine Branch: master Commit: 91ed2a81c1658a117cb369da3a8bc568aaf6e86f URL: http://source.winehq.org/git/wine.git/?a=commit;h=91ed2a81c1658a117cb369da3a... Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Tue Nov 10 23:07:58 2015 +0300 riched20: Fix a memory leak on error path (Coverity). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/riched20/editor.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index bbb0cc0..28c845c 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1268,12 +1268,10 @@ static void ME_RTFReadShpPictGroup( RTF_Info *info ) static DWORD read_hex_data( RTF_Info *info, BYTE **out ) { DWORD read = 0, size = 1024; - BYTE *buf = HeapAlloc( GetProcessHeap(), 0, size ); - BYTE val; + BYTE *buf, val; BOOL flip; *out = NULL; - if (!buf) return 0; if (info->rtfClass != rtfText) { @@ -1281,6 +1279,9 @@ static DWORD read_hex_data( RTF_Info *info, BYTE **out ) return 0; } + buf = HeapAlloc( GetProcessHeap(), 0, size ); + if (!buf) return 0; + val = info->rtfMajor; for (flip = TRUE;; flip = !flip) {