BSON C-Extension: Remove attempted use of memory buffer after deallocation

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.9.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In the legacy BSON C-extension, we're attempting to use a byte buffer in an error message to get the buffer's size after we've already deallocated it:

      if (length > bson_buffer_get_max_size(buffer)) {
          bson_buffer_free(buffer);
          rb_raise(InvalidDocument,
            "Document too large: This BSON document is limited to %d bytes.",
            bson_buffer_get_max_size(buffer));
          return;
      }
      

      Link:
      https://github.com/mongodb/mongo-ruby-driver/blob/master/ext/cbson/cbson.c#L603-L610

              Assignee:
              Brandon Black (Inactive)
              Reporter:
              Brandon Black (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: