--- pbx.c 2013-11-18 15:06:43.692834542 +0200 +++ pbx.c-20131118 2013-11-18 15:11:38.860822129 +0200 @@ -9030,7 +9030,7 @@ { char *info; int j, num_fields, last_sep = -1; - + /* Check for empty just in case */ if (ast_strlen_zero(info_in)) { return 0; @@ -10954,12 +10954,19 @@ branch2 = strsep(&ts,""); /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */ - if (ast_build_timing(&timing, s) && ast_check_timing2(&timing, tv)) { + /* Need to check whether timing was actually built here. If not, we don't want to try and destroy it later + as that will cause a seg fault + */ + int built_timing = 0; + if ((built_timing = ast_build_timing(&timing, s)) && ast_check_timing2(&timing, tv)) { branch = branch1; } else { branch = branch2; } - ast_destroy_timing(&timing); + /* Only try and destroy this struct if it was actually initialized */ + if (built_timing == 1) { + ast_destroy_timing(&timing); + } if (ast_strlen_zero(branch)) { ast_debug(1, "Not taking any branch\n"); @@ -10994,7 +11001,8 @@ if (!ast_build_timing(&timing, s)) { ast_log(LOG_WARNING, "Invalid Time Spec: %s\nCorrect usage: %s\n", s, usage); - ast_destroy_timing(&timing); + /* The below statement is superflous and will cause a segmentation fault as timing is never initiated if ast_build_timing returns 0 */ + //ast_destroy_timing(&timing); return -1; }