[PATCH v3 0/1] MR4323: pdh: Introduce memory barrier in destroy operations.
gcc tends to optimize away the magic field cleanup, leading to believe the query is still allocated. Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> -- v3: pdh: Zero out magic fields with SecureZeroMemory(). https://gitlab.winehq.org/wine/wine/-/merge_requests/4323
From: Eric Pouech <epouech(a)codeweavers.com> gcc tends to optimize away the magic field cleanup, leading to believe the query is still allocated. Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- dlls/pdh/pdh_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/pdh/pdh_main.c b/dlls/pdh/pdh_main.c index 073a74e1b52..12bda6bedc0 100644 --- a/dlls/pdh/pdh_main.c +++ b/dlls/pdh/pdh_main.c @@ -97,7 +97,8 @@ static struct counter *create_counter( void ) static void destroy_counter( struct counter *counter ) { - counter->magic = 0; + /* Ensure compiler doesn't optimize out the assignment with 0. */ + SecureZeroMemory( &counter->magic, sizeof( counter->magic ) ); free( counter->path ); free( counter ); } @@ -130,7 +131,8 @@ static struct query *create_query( void ) static void destroy_query( struct query *query ) { - query->magic = 0; + /* Ensure compiler doesn't optimize out the assignment with 0. */ + SecureZeroMemory( &query->magic, sizeof( query->magic ) ); free( query ); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4323
participants (2)
-
Eric Pouech -
eric pouech (@epo)