Skip to content

Commit

Permalink
db_mongodb: clone bson UTF8 value into DB val structure
Browse files Browse the repository at this point in the history
- the bson iterator invalidates or reuses the memory after several interations
- initial patch by Konstantin Poliakov <k.polyakov@mightycall.com>, GH #1508
  • Loading branch information
miconda committed Apr 25, 2018
1 parent cffd8bd commit 1ef70d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/modules/db_mongodb/mongodb_dbase.c
Expand Up @@ -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:
Expand Down

0 comments on commit 1ef70d6

Please sign in to comment.