-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
Here we're allocating memory for a new buffer, then attempting to call bson_buffer_set_max_size before performing a null check. At this point in this code path, the null check isn't necessary and should be done before we try to set the buffer's max_size.
bson_buffer_t buffer = bson_buffer_new(); bson_buffer_set_max_size(buffer, FIX2INT(max_size)); if (buffer == NULL) { rb_raise(rb_eNoMemError, "failed to allocate memory in buffer.c"); }
Link:
https://github.com/mongodb/mongo-ruby-driver/blob/master/ext/cbson/cbson.c#L618-L622