Huw Davies : setupapi: Fix memory leak.
Alexandre Julliard
julliard at winehq.org
Mon Dec 7 10:26:15 CST 2009
Module: wine
Branch: master
Commit: 63231be8044441218fb82899e748900e1ace3d0d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=63231be8044441218fb82899e748900e1ace3d0d
Author: Huw Davies <huw at codeweavers.com>
Date: Sun Dec 6 17:04:00 2009 +0000
setupapi: Fix memory leak.
Found by Valgrind.
---
dlls/setupapi/queue.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c
index 6c9ca64..6a2b8d6 100644
--- a/dlls/setupapi/queue.c
+++ b/dlls/setupapi/queue.c
@@ -722,8 +722,9 @@ BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf,
{
SP_FILE_COPY_PARAMS_W params;
INFCONTEXT context;
- WCHAR dest[MAX_PATH], src[MAX_PATH];
+ WCHAR dest[MAX_PATH], src[MAX_PATH], *dest_dir;
INT flags;
+ BOOL ret = FALSE;
TRACE( "hinf=%p/%p section=%s root=%s\n",
hinf, hlist, debugstr_w(section), debugstr_w(src_root) );
@@ -742,18 +743,21 @@ BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf,
if (!hlist) hlist = hinf;
if (!hinf) hinf = hlist;
if (!SetupFindFirstLineW( hlist, section, NULL, &context )) return FALSE;
- if (!(params.TargetDirectory = get_destination_dir( hinf, section ))) return FALSE;
+ if (!(params.TargetDirectory = dest_dir = get_destination_dir( hinf, section ))) return FALSE;
do
{
if (!SetupGetStringFieldW( &context, 1, dest, sizeof(dest)/sizeof(WCHAR), NULL ))
- return FALSE;
+ goto end;
if (!SetupGetStringFieldW( &context, 2, src, sizeof(src)/sizeof(WCHAR), NULL )) *src = 0;
if (!SetupGetIntField( &context, 4, &flags )) flags = 0; /* FIXME */
params.SourceFilename = *src ? src : NULL;
- if (!SetupQueueCopyIndirectW( ¶ms )) return FALSE;
+ if (!SetupQueueCopyIndirectW( ¶ms )) goto end;
} while (SetupFindNextLine( &context, &context ));
- return TRUE;
+ ret = TRUE;
+end:
+ HeapFree(GetProcessHeap(), 0, dest_dir);
+ return ret;
}
More information about the wine-cvs
mailing list