Author: coreyfarrell
Date: Sat Nov  8 12:17:13 2014
New Revision: 427557

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=427557
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

Modified:
    branches/13/   (props changed)
    branches/13/channels/chan_console.c

Propchange: branches/13/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: branches/13/channels/chan_console.c
URL: 
http://svnview.digium.com/svn/asterisk/branches/13/channels/chan_console.c?view=diff&rev=427557&r1=427556&r2=427557
==============================================================================
--- branches/13/channels/chan_console.c (original)
+++ branches/13/channels/chan_console.c Sat Nov  8 12:17:13 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;


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to