sal/osl/w32/backtrace.cxx |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

New commits:
commit fdf84b42a09fa2eed03dccfaeec98dba720e6557
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Feb 3 07:42:57 2022 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Feb 3 10:52:47 2022 +0100

    Call SymInitialize only once
    
    Also simplify the logic by passing fInvadeProcess = false there, since
    passing true is the same as calling SymRefreshModuleList explicitly.
    
    Fixes an overlook from commit 853a058ca6b75b0fb14e232911eb9f9553574736.
    
    Change-Id: I296f06845a9f92375908d72e69574c2ecd190028
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129338
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sal/osl/w32/backtrace.cxx b/sal/osl/w32/backtrace.cxx
index fab3c5043a60..d9231de44517 100644
--- a/sal/osl/w32/backtrace.cxx
+++ b/sal/osl/w32/backtrace.cxx
@@ -61,13 +61,9 @@ OUString sal::backtrace_to_string(BacktraceState* 
backtraceState)
 {
     HANDLE hProcess = GetCurrentProcess();
     // 
https://docs.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-syminitialize
-    // says to not initialize more than once. This still leaks for some
-    // reason if called often enough.
-    static bool needsInit = true;
-    if( needsInit )
-        SymInitialize( hProcess, nullptr, true );
-    else
-        SymRefreshModuleList( hProcess );
+    // says to not initialize more than once.
+    [[maybe_unused]] static bool bInitialized = SymInitialize(hProcess, 
nullptr, false);
+    SymRefreshModuleList(hProcess);
     SYMBOL_INFO  * pSymbol;
     pSymbol = static_cast<SYMBOL_INFO *>(calloc( sizeof( SYMBOL_INFO ) + 1024 
* sizeof( char ), 1 ));
     assert(pSymbol);

Reply via email to