And here you should replace free for bson_free()