Module: kamailio
Branch: master
Commit: 0d9e4adb328dabaf2a34d926bc80e022bee65079
URL:
https://github.com/kamailio/kamailio/commit/0d9e4adb328dabaf2a34d926bc80e02…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-08-25T14:28:17+02:00
dialog: dlg var value stored as zero terminated string
- easier to use in std lib operations
---
Modified: modules/dialog/dlg_var.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0d9e4adb328dabaf2a34d926bc80e02…
Patch:
https://github.com/kamailio/kamailio/commit/0d9e4adb328dabaf2a34d926bc80e02…
---
diff --git a/modules/dialog/dlg_var.c b/modules/dialog/dlg_var.c
index a3c7b8e..e8c84ed 100644
--- a/modules/dialog/dlg_var.c
+++ b/modules/dialog/dlg_var.c
@@ -99,7 +99,7 @@ static inline struct dlg_var *new_dlg_var(str *key, str *val)
LM_ERR("no more shm mem\n");
return NULL;
}
- var->next = NULL;
+ memset(var, 0, sizeof(struct dlg_var));
var->vflags = DLG_FLAG_NEW;
/* set key */
var->key.len = key->len;
@@ -113,7 +113,7 @@ static inline struct dlg_var *new_dlg_var(str *key, str *val)
var->key.s[var->key.len] = '\0';
/* set value */
var->value.len = val->len;
- var->value.s = (char*)shm_malloc(var->value.len);
+ var->value.s = (char*)shm_malloc(var->value.len+1);
if (var->value.s==NULL) {
shm_free(var->key.s);
shm_free(var);
@@ -121,6 +121,7 @@ static inline struct dlg_var *new_dlg_var(str *key, str *val)
return NULL;
}
memcpy(var->value.s, val->s, val->len);
+ var->value.s[var->value.len] = '\0';
return var;
}