InterlockedExchangePointer() is needed to ensure other threads which access
_scprintf and _scwprintf import pointers after the assignment will see the
new updated value.
---
mingw-w64-crt/stdio/_scprintf.c | 2 +-
mingw-w64-crt/stdio/_scwprintf.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-crt/stdio/_scprintf.c b/mingw-w64-crt/stdio/_scprintf.c
index 8dabf95df08d..905e0d2580ee 100644
--- a/mingw-w64-crt/stdio/_scprintf.c
+++ b/mingw-w64-crt/stdio/_scprintf.c
@@ -45,7 +45,7 @@ static void resolve_scprintf(void)
if (!func)
func = emu_scprintf;
- __MINGW_IMP_SYMBOL(_scprintf) = func;
+ (void)InterlockedExchangePointer((PVOID*)&__MINGW_IMP_SYMBOL(_scprintf),
func);
}
/* gcc does not provide an easy way to call another variadic function with
reusing current arguments
diff --git a/mingw-w64-crt/stdio/_scwprintf.c b/mingw-w64-crt/stdio/_scwprintf.c
index e92479fd8690..c5464595644b 100644
--- a/mingw-w64-crt/stdio/_scwprintf.c
+++ b/mingw-w64-crt/stdio/_scwprintf.c
@@ -45,7 +45,7 @@ static void resolve_scwprintf(void)
if (!func)
func = emu_scwprintf;
- __MINGW_IMP_SYMBOL(_scwprintf) = func;
+ (void)InterlockedExchangePointer((PVOID*)&__MINGW_IMP_SYMBOL(_scwprintf),
func);
}
/* gcc does not provide an easy way to call another variadic function with
reusing current arguments
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public