[asterisk-commits] coreyfarrell: trunk r427566 - in /trunk: ./ channels/chan_console.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Nov 8 12:20:46 CST 2014
Author: coreyfarrell
Date: Sat Nov 8 12:20:43 2014
New Revision: 427566
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=427566
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/
........
Merged revisions 427554 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 427555 from http://svn.asterisk.org/svn/asterisk/branches/12
........
Merged revisions 427557 from http://svn.asterisk.org/svn/asterisk/branches/13
Modified:
trunk/ (props changed)
trunk/channels/chan_console.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.
Modified: trunk/channels/chan_console.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_console.c?view=diff&rev=427566&r1=427565&r2=427566
==============================================================================
--- trunk/channels/chan_console.c (original)
+++ trunk/channels/chan_console.c Sat Nov 8 12:20:43 2014
@@ -712,7 +712,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) {
@@ -729,6 +729,7 @@
return NULL;
}
+ pvt = get_active_pvt();
if (!pvt) {
ast_cli(a->fd, "No console device is set as active.\n");
return CLI_FAILURE;
@@ -759,7 +760,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";
@@ -767,16 +768,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");
@@ -797,7 +801,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";
@@ -805,16 +809,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;
@@ -869,7 +876,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";
@@ -877,16 +884,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");
@@ -906,7 +916,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) {
@@ -915,16 +925,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"))
@@ -1053,7 +1066,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:
@@ -1067,6 +1080,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;
@@ -1103,7 +1117,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,
@@ -1117,9 +1131,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