BSONColumn::Iterator::DecodingState::Decoder64 default constructor leaves scaleIndex uninitialized

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Execution
    • ALL
    • Storage Execution 2026-08-03
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In src/mongo/bson/bsoncolumn.h, the default constructor `Decoder64() = default;` initializes only members with default member initializers and does not initialize `scaleIndex` (a raw `uint8_t`), which has no default member initializer. A default-constructed instance therefore holds an indeterminate `scaleIndex`.

      The `scaleIndex` member is used internally by `Decoder64` during BSONColumn materialization. Reading the indeterminate value before explicit assignment constitutes undefined behavior. While the practical impact may be limited if the member is always set before use in practice, the uninitialized read remains UB and should be fixed to ensure code correctness and eliminate static analysis warnings.

      Found by static analysis (Svace, UNINIT.CTOR): "Constructor declared at bsoncolumn.h:350 may not initialize class members of 'mongo::BSONColumn::Iterator::DecodingState::Decoder64'. Following members aren't initialized: scaleIndex."

      Suggested fix: initialize `scaleIndex` in the default constructor (e.g., `Decoder64() : scaleIndex(0) {}`) or give it a default member initializer (`uint8_t scaleIndex = 0;`).

            Assignee:
            Binh Vo
            Reporter:
            Петя Вдовин (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: