Module: kamailio
Branch: master
Commit: 6bd32088de1d7ae816643aea4a60c70911e46b5e
URL:
https://github.com/kamailio/kamailio/commit/6bd32088de1d7ae816643aea4a60c70…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-03-07T23:25:27+01:00
db_mongodb: re-init iterator for bson covert search failure
---
Modified: src/modules/db_mongodb/mongodb_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6bd32088de1d7ae816643aea4a60c70…
Patch:
https://github.com/kamailio/kamailio/commit/6bd32088de1d7ae816643aea4a60c70…
---
diff --git a/src/modules/db_mongodb/mongodb_dbase.c
b/src/modules/db_mongodb/mongodb_dbase.c
index 759b1c6..048d71c 100644
--- a/src/modules/db_mongodb/mongodb_dbase.c
+++ b/src/modules/db_mongodb/mongodb_dbase.c
@@ -529,9 +529,15 @@ static int db_mongodb_convert_bson(const db1_con_t* _h, db1_res_t*
_r,
LM_DBG("looking for field[%d] named: %s\n", col, colname);
if(mgres->colsdoc) {
if(!bson_iter_find(&riter, colname)) {
- LM_ERR("field [%s] not found in result iterator\n",
+ if (!bson_iter_init (&riter, _rdoc)) {
+ LM_ERR("failed to initialize result iterator\n");
+ return -3;
+ }
+ if(!bson_iter_find(&riter, colname)) {
+ LM_ERR("field [%s] not found in result iterator\n",
colname);
- return -4;
+ return -4;
+ }
}
piter = &riter;
} else {