https://git.reactos.org/?p=reactos.git;a=commitdiff;h=63cf8625a055e04c0e1619fd4f59609aaa5b1d8b

commit 63cf8625a055e04c0e1619fd4f59609aaa5b1d8b
Author:     Serge Gautherie <[email protected]>
AuthorDate: Sat Jan 18 18:53:11 2020 +0100
Commit:     Hermès BÉLUSCA - MAÏTO <[email protected]>
CommitDate: Sat Jan 18 18:53:11 2020 +0100

    [WBEMPROX] Always free 'new_path' (#2056)
    
    Cherry-pick
    
https://source.winehq.org/git/wine.git/commit/a45dfea99a2eeaf3ede829b04e58c13d14b33970
    
    CORE-13391
---
 dll/win32/wbemprox/builtin.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/dll/win32/wbemprox/builtin.c b/dll/win32/wbemprox/builtin.c
index b92231c8152..d2ad7376191 100644
--- a/dll/win32/wbemprox/builtin.c
+++ b/dll/win32/wbemprox/builtin.c
@@ -2408,7 +2408,13 @@ static enum fill_status fill_datafile( struct table 
*table, const struct expr *c
                         goto done;
                     }
                     if (!wcscmp( data.cFileName, dotW ) || !wcscmp( 
data.cFileName, dotdotW )) continue;
-                    new_path = append_path( path, data.cFileName, &len );
+
+                    if (!(new_path = append_path( path, data.cFileName, &len 
)))
+                    {
+                        status = FILL_STATUS_FAILED;
+                        FindClose( handle );
+                        goto done;
+                    }
 
                     if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                     {
@@ -2421,6 +2427,7 @@ static enum fill_status fill_datafile( struct table 
*table, const struct expr *c
                     rec = (struct record_datafile *)(table->data + offset);
                     rec->name    = build_name( root[0], new_path );
                     rec->version = get_file_version( rec->name );
+                    heap_free( new_path );
                     if (!match_row( table, row, cond, &status ))
                     {
                         free_row_values( table, row );
@@ -2532,7 +2539,13 @@ static enum fill_status fill_directory( struct table 
*table, const struct expr *
                         !wcscmp( data.cFileName, dotW ) || !wcscmp( 
data.cFileName, dotdotW ))
                         continue;
 
-                    new_path = append_path( path, data.cFileName, &len );
+                    if (!(new_path = append_path( path, data.cFileName, &len 
)))
+                    {
+                        FindClose( handle );
+                        status = FILL_STATUS_FAILED;
+                        goto done;
+                    }
+
                     if (!(push_dir( dirstack, new_path, len )))
                     {
                         heap_free( new_path );
@@ -2543,6 +2556,7 @@ static enum fill_status fill_directory( struct table 
*table, const struct expr *
                     rec = (struct record_directory *)(table->data + offset);
                     rec->accessmask = FILE_ALL_ACCESS;
                     rec->name       = build_name( root[0], new_path );
+                    heap_free( new_path );
                     if (!match_row( table, row, cond, &status ))
                     {
                         free_row_values( table, row );

Reply via email to