mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
pbx.c: On error, ast_add_extension2_lockopt should always free 'data'
In the event that the desired extension already exists, ast_add_extension2_lockopt() will free the 'data' it is passed before returning an error, so we should not be freeing it ourselves. Additionally, there were two places where ast_add_extension2_lockopt() could return an error without also freeing the 'data' pointer, so we add that. ASTERISK-29097 #close Change-Id: I904707aae55169feda050a5ed7c6793b53fe6eae
This commit is contained in:
committed by
Friendly Automation
parent
773f424c7f
commit
51cba591e3
12
main/pbx.c
12
main/pbx.c
@@ -7346,6 +7346,10 @@ static int ast_add_extension2_lockopt(struct ast_context *con,
|
||||
if (ast_strlen_zero(extension)) {
|
||||
ast_log(LOG_ERROR,"You have to be kidding-- add exten '' to context %s? Figure out a name and call me back. Action ignored.\n",
|
||||
con->name);
|
||||
/* We always need to deallocate 'data' on failure */
|
||||
if (datad) {
|
||||
datad(data);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -7401,8 +7405,14 @@ static int ast_add_extension2_lockopt(struct ast_context *con,
|
||||
}
|
||||
|
||||
/* Be optimistic: Build the extension structure first */
|
||||
if (!(tmp = ast_calloc(1, length)))
|
||||
tmp = ast_calloc(1, length);
|
||||
if (!tmp) {
|
||||
/* We always need to deallocate 'data' on failure */
|
||||
if (datad) {
|
||||
datad(data);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ast_strlen_zero(label)) /* let's turn empty labels to a null ptr */
|
||||
label = 0;
|
||||
|
Reference in New Issue
Block a user