Browse Source

modules/dialog_ng: fixed bad append bug and added null sentinel
- thanks Hugh

Jason Penton 12 years ago
parent
commit
68a8ef2ed9
1 changed files with 4 additions and 3 deletions
  1. 4 3
      modules/dialog_ng/dlg_hash.c

+ 4 - 3
modules/dialog_ng/dlg_hash.c

@@ -1267,15 +1267,16 @@ int dlg_set_toroute(struct dlg_cell *dlg, str * route) {
  * \return void
  */
 void create_concurrent_did(struct dlg_cell *dlg, str * new_did) {
-    int len  = dlg->did.len + 1;
+    int len  = dlg->did.len + 1 + 1;
     new_did->s = shm_malloc(len);
     if (new_did->s == 0) {
         LM_ERR("no more shm mem (%d)\n", len);
         return;
     }
+    memset(new_did->s, 0, len);
     memcpy(new_did->s, dlg->did.s, dlg->did.len);
-    new_did->s[len]= 'x';
-    new_did->len = len;
+    new_did->s[dlg->did.len] = 'x';
+    new_did->len = dlg->did.len + 1;
 }
 
 /*!