Module: kamailio Branch: master Commit: 1ef70d68599db092fa71b9b8b7cd3fdcd54f8a99 URL: https://github.com/kamailio/kamailio/commit/1ef70d68599db092fa71b9b8b7cd3fdc...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-04-25T14:43:42+02:00
db_mongodb: clone bson UTF8 value into DB val structure
- the bson iterator invalidates or reuses the memory after several interations - initial patch by Konstantin Poliakov k.polyakov@mightycall.com, GH #1508
---
Modified: src/modules/db_mongodb/mongodb_dbase.c
---
Diff: https://github.com/kamailio/kamailio/commit/1ef70d68599db092fa71b9b8b7cd3fdc... Patch: https://github.com/kamailio/kamailio/commit/1ef70d68599db092fa71b9b8b7cd3fdc...
---
diff --git a/src/modules/db_mongodb/mongodb_dbase.c b/src/modules/db_mongodb/mongodb_dbase.c index 91207973f1..5e8e63d618 100644 --- a/src/modules/db_mongodb/mongodb_dbase.c +++ b/src/modules/db_mongodb/mongodb_dbase.c @@ -632,7 +632,13 @@ static int db_mongodb_convert_bson(const db1_con_t* _h, db1_res_t* _r, break;
case BSON_TYPE_UTF8: - VAL_STRING(dval) = (char*)bson_iter_utf8 (piter, &i32tmp); + { + char* rstring = (char*)bson_iter_utf8 (piter, &i32tmp); + if(db_str2val(DB1_STRING, dval, rstring, i32tmp, 1)<0) { + LM_ERR("failed to convert utf8 value\n"); + return -5; + } + } break;
case BSON_TYPE_OID: