mongodb: fixes crash when the return of `mongoc_cursor_current` was freed
authorAlexandre Terrasa <alexandre@moz-code.org>
Sun, 29 Nov 2015 20:35:14 +0000 (15:35 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Sun, 29 Nov 2015 20:35:14 +0000 (15:35 -0500)
commit65942d13e0fb20e27d37d025457ccfbca1190da7
tree7f105c7ac989f7934fdd805f6d685fe9d61639e6
parent6b72ea3d8d5e698c5b7154781e652a5355767103
mongodb: fixes crash when the return of `mongoc_cursor_current` was freed

As explained by the documentation (that I should have read more thoroughly...),
`bson_t` structures allocated by the `mongoc_cursor_current` function should not be freed by the user.

Before this commit, the `bson_t` returned by `mongoc_cursor_current` where left as this then freed
by the nit GC.

This commit makes the `current` method to return a copy of the `bson_t` struct so
it can be freed safely by the GC later.

And... this is why I fear and hate the C programming language... :)

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
lib/mongodb/mongodb.nit
lib/mongodb/native_mongodb.nit