[asterisk-commits] coreyfarrell: branch 12 r427555 - in /branches/12: ./ channels/chan_console.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Nov 8 11:30:10 CST 2014
Author: coreyfarrell
Date: Sat Nov 8 11:30:06 2014
New Revision: 427555
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=427555
Log:
chan_console: Fix reference leaks to pvt.
Fix a bunch of calls to get_active_pvt
where the reference is never released.
ASTERISK-24504 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/4152/
Modified:
branches/12/ (props changed)
branches/12/channels/chan_console.c
Propchange: branches/12/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.
Modified: branches/12/channels/chan_console.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/channels/chan_console.c?view=diff&rev=427555&r1=427554&r2=427555
==============================================================================
--- branches/12/channels/chan_console.c (original)
+++ branches/12/channels/chan_console.c Sat Nov 8 11:30:06 2014
@@ -701,7 +701,7 @@
static char *cli_console_autoanswer(struct ast_cli_entry *e, int cmd,
struct ast_cli_args *a)
{
- struct console_pvt *pvt = get_active_pvt();
+ struct console_pvt *pvt;
char *res = CLI_SUCCESS;
switch (cmd) {
@@ -718,6 +718,7 @@
return NULL;
}
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is set as active.\n");
return CLI_FAILURE;
@@ -748,7 +749,7 @@
static char *cli_console_flash(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct console_pvt *pvt = get_active_pvt();
+ struct console_pvt *pvt;
if (cmd == CLI_INIT) {
e->command = "console flash";
@@ -756,16 +757,19 @@
"Usage: console flash\n"
" Flashes the call currently placed on the console.\n";
return NULL;
- } else if (cmd == CLI_GENERATE)
- return NULL;
-
+ } else if (cmd == CLI_GENERATE) {
+ return NULL;
+ }
+
+ if (a->argc != e->args) {
+ return CLI_SHOWUSAGE;
+ }
+
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is set as active\n");
return CLI_FAILURE;
}
-
- if (a->argc != e->args)
- return CLI_SHOWUSAGE;
if (!pvt->owner) {
ast_cli(a->fd, "No call to flash\n");
@@ -786,7 +790,7 @@
{
char *s = NULL;
const char *mye = NULL, *myc = NULL;
- struct console_pvt *pvt = get_active_pvt();
+ struct console_pvt *pvt;
if (cmd == CLI_INIT) {
e->command = "console dial";
@@ -794,16 +798,19 @@
"Usage: console dial [extension[@context]]\n"
" Dials a given extension (and context if specified)\n";
return NULL;
- } else if (cmd == CLI_GENERATE)
- return NULL;
-
+ } else if (cmd == CLI_GENERATE) {
+ return NULL;
+ }
+
+ if (a->argc > e->args + 1) {
+ return CLI_SHOWUSAGE;
+ }
+
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is currently set as active\n");
return CLI_FAILURE;
}
-
- if (a->argc > e->args + 1)
- return CLI_SHOWUSAGE;
if (pvt->owner) { /* already in a call */
int i;
@@ -858,7 +865,7 @@
static char *cli_console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct console_pvt *pvt = get_active_pvt();
+ struct console_pvt *pvt;
if (cmd == CLI_INIT) {
e->command = "console hangup";
@@ -866,16 +873,19 @@
"Usage: console hangup\n"
" Hangs up any call currently placed on the console.\n";
return NULL;
- } else if (cmd == CLI_GENERATE)
- return NULL;
-
+ } else if (cmd == CLI_GENERATE) {
+ return NULL;
+ }
+
+ if (a->argc != e->args) {
+ return CLI_SHOWUSAGE;
+ }
+
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is set as active\n");
return CLI_FAILURE;
}
-
- if (a->argc != e->args)
- return CLI_SHOWUSAGE;
if (!pvt->owner && !pvt->hookstate) {
ast_cli(a->fd, "No call to hang up\n");
@@ -895,7 +905,7 @@
static char *cli_console_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
const char *s;
- struct console_pvt *pvt = get_active_pvt();
+ struct console_pvt *pvt;
char *res = CLI_SUCCESS;
if (cmd == CLI_INIT) {
@@ -904,16 +914,19 @@
"Usage: console {mute|unmute}\n"
" Mute/unmute the microphone.\n";
return NULL;
- } else if (cmd == CLI_GENERATE)
- return NULL;
-
+ } else if (cmd == CLI_GENERATE) {
+ return NULL;
+ }
+
+ if (a->argc != e->args) {
+ return CLI_SHOWUSAGE;
+ }
+
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is set as active\n");
return CLI_FAILURE;
}
-
- if (a->argc != e->args)
- return CLI_SHOWUSAGE;
s = a->argv[e->args-1];
if (!strcasecmp(s, "mute"))
@@ -1042,7 +1055,7 @@
*/
static char *cli_console_answer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct console_pvt *pvt = get_active_pvt();
+ struct console_pvt *pvt;
switch (cmd) {
case CLI_INIT:
@@ -1056,6 +1069,7 @@
return NULL; /* no completion */
}
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is set as active\n");
return CLI_FAILURE;
@@ -1092,7 +1106,7 @@
static char *cli_console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
char buf[TEXT_SIZE];
- struct console_pvt *pvt = get_active_pvt();
+ struct console_pvt *pvt;
struct ast_frame f = {
.frametype = AST_FRAME_TEXT,
.data.ptr = buf,
@@ -1106,9 +1120,11 @@
"Usage: console send text <message>\n"
" Sends a text message for display on the remote terminal.\n";
return NULL;
- } else if (cmd == CLI_GENERATE)
- return NULL;
-
+ } else if (cmd == CLI_GENERATE) {
+ return NULL;
+ }
+
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is set as active\n");
return CLI_FAILURE;
More information about the asterisk-commits
mailing list