Audit array allocations

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Unknown
    • 2.2.0
    • Affects Version/s: None
    • Component/s: None
    • Not Needed
    • 🔵 Done
    • C Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      There are several points in the codebase that use (bson_)malloc(sizeof(T) * N) to allocate arrays of objects. This should not do an in-situ multiplication, since a large value of N will cause integer overflow and result in either an allocation failure or a bogus allocation size. Also, N = 0 can cause issues since malloc(0) is undefined/unspecified.

      Proposal: A new function-like macro for allocating arrays, e.g. bson_allocate_array(T, N) that allocates aligned zero-filled storage for N objects of type T and also handles N = 0 properly.

            Assignee:
            Julia Garland
            Reporter:
            Colby Pike
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: