add more paranoid handling to pbx_builtin_serialize_variables
authorAnthony Minessale II <anthmct@yahoo.com>
Wed, 27 Oct 2004 01:34:06 +0000 (01:34 +0000)
committerAnthony Minessale II <anthmct@yahoo.com>
Wed, 27 Oct 2004 01:34:06 +0000 (01:34 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4107 65c4cc65-6c06-0410-ace0-fbb531ad65f3

pbx.c

diff --git a/pbx.c b/pbx.c
index e40746d..c6d7e3f 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -4921,18 +4921,21 @@ int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t
 {
        struct ast_var_t *variables;
        struct varshead *headp;
+       char *var=NULL ,*val=NULL;
        int total = 0;
 
        memset(buf,0,size);
        if (chan) {
                headp=&chan->varshead;
                AST_LIST_TRAVERSE(headp,variables,entries) {
-                       snprintf(buf + strlen(buf), size - strlen(buf), "%s=%s\n", ast_var_name(variables), ast_var_value(variables));
-                       if(strlen(buf) >= size) {
-                               ast_log(LOG_ERROR,"Data Buffer Size Exceeded!\n");
-                               break;
+                       if(chan && variables && (var=ast_var_name(variables)) && (val=ast_var_value(variables))) {
+                               snprintf(buf + strlen(buf), size - strlen(buf), "%s=%s\n", var, val);
+                               if(strlen(buf) >= size) {
+                                       ast_log(LOG_ERROR,"Data Buffer Size Exceeded!\n");
+                                       break;
+                               }
+                               total++;
                        }
-                       total++;
                }
        }