mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
Fix error paths in action_hangup() for AMI Hangup action.
* Check allocation function return values for failure. Crashing is bad. * Tweak ast_regex_string_to_regex_pattern() parameters for proper ast_str usage. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368714 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1362,20 +1362,20 @@ int ast_build_string(char **buffer, size_t *space, const char *fmt, ...)
|
||||
return result;
|
||||
}
|
||||
|
||||
int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str *regex_pattern)
|
||||
int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str **regex_pattern)
|
||||
{
|
||||
int regex_len = strlen(regex_string);
|
||||
int ret = 3;
|
||||
|
||||
/* Chop off the leading / if there is one */
|
||||
if ((regex_len >= 1) && (regex_string[0] == '/')) {
|
||||
ast_str_set(®ex_pattern, 0, "%s", regex_string + 1);
|
||||
ast_str_set(regex_pattern, 0, "%s", regex_string + 1);
|
||||
ret -= 2;
|
||||
}
|
||||
|
||||
/* Chop off the ending / if there is one */
|
||||
if ((regex_len > 1) && (regex_string[regex_len - 1] == '/')) {
|
||||
ast_str_truncate(regex_pattern, -1);
|
||||
ast_str_truncate(*regex_pattern, -1);
|
||||
ret -= 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user