Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7253

Do not use indirect pointer to call 'snprintf'

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.2, 2.3.0
    • Affects Version/s: 2.0.7, 2.2.0
    • Component/s: Internal Code
    • Labels:
      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.

            Assignee:
            tad Tad Marshall
            Reporter:
            tad Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: