-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.7, 2.2.0
-
Component/s: Internal Code
-
None
-
Minor Change
-
ALL
In src/mongo/bson/util/builder.h in lines 250 to 256, we create a static initializer used to call sprintf_s on Windows or snprintf on other platforms. This makes it possible to crash at startup if another static initializer tries to use this function pointer before this one has run. Since the order in which static initializers run is unspecified by the C++ standard, this should be coded differently.
Since Windows has a '_snprintf' function that does what 'snprintf' does on other platforms, this code can be replaced by a macro.