]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pbx.c: Pre-initialize timezone to avoid crash on destroy
authorScott Griepentrog <sgriepentrog@digium.com>
Wed, 22 Jan 2014 22:16:47 +0000 (22:16 +0000)
committerScott Griepentrog <sgriepentrog@digium.com>
Wed, 22 Jan 2014 22:16:47 +0000 (22:16 +0000)
In ast_build_timing, initialize the timezone value to NULL
in order to avoid deferencing an uninitialized value later
when calling ast_destroy_timing.  The timezone value could
be uninitialized if ast_build_timing were to fail due to a
zero length time string.

(closes issue ASTERISK-22861)
Reported by: Sebastian Murray-Roberts
Review: https://reviewboard.asterisk.org/r/3134/
Patches:
     ast_build_timing-initialize-timezone.patch uploaded by coreyfarrell (license 5909)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@406241 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/pbx.c
utils/extconf.c

index e370ae7431b00711426ee70d3ef160c4152254a1..241d0641a7cf90bc005dcc5234a3e37375601085 100644 (file)
@@ -8239,6 +8239,8 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        char *info;
        int j, num_fields, last_sep = -1;
 
+       i->timezone = NULL;
+
        /* Check for empty just in case */
        if (ast_strlen_zero(info_in)) {
                return 0;
@@ -8258,8 +8260,6 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        /* save the timezone, if it is specified */
        if (num_fields == 5) {
                i->timezone = ast_strdup(info + last_sep + 1);
-       } else {
-               i->timezone = NULL;
        }
 
        /* Assume everything except time */
index 99df9e9ec1e59caf4f3ff3378b4d1f841f26225b..7131e13b1738ae6dc52b10e9efc1a10d531efa82 100644 (file)
@@ -4439,6 +4439,8 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        char *info;
        int j, num_fields, last_sep = -1;
 
+       i->timezone = NULL;
+
        /* Check for empty just in case */
        if (ast_strlen_zero(info_in)) {
                return 0;
@@ -4458,8 +4460,6 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        /* save the timezone, if it is specified */
        if (num_fields == 5) {
                i->timezone = ast_strdup(info + last_sep + 1);
-       } else {
-               i->timezone = NULL;
        }
 
        /* Assume everything except time */