nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
941110f
)
lib/mongodb: fix segfault in `Collection::find` method
author
Alexandre Terrasa
<alexandre@moz-code.org>
Fri, 16 Oct 2015 15:10:05 +0000
(11:10 -0400)
committer
Alexandre Terrasa
<alexandre@moz-code.org>
Fri, 16 Oct 2015 15:12:21 +0000
(11:12 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
lib/mongodb/mongodb.nit
patch
|
blob
|
history
diff --git
a/lib/mongodb/mongodb.nit
b/lib/mongodb/mongodb.nit
index
416e36b
..
624dc8a
100644
(file)
--- a/
lib/mongodb/mongodb.nit
+++ b/
lib/mongodb/mongodb.nit
@@
-600,8
+600,9
@@
class MongoCollection
# ~~~
fun find(query: JsonObject): nullable JsonObject do
assert is_alive
- var c = native.find(query.to_bson.native)
- assert is_alive # FIXME used to avoid segfault (so `self` isn't garbage collected to soon)
+ var q = new NativeBSON.from_json_string(query.to_json.to_cstring)
+ var c = native.find(q)
+ q.destroy
if c == null then return null
var cursor = new MongoCursor(c)
if cursor.is_ok then return cursor.item