]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Avoid a potential NULL dereference.
authorTilghman Lesher <tilghman@meg.abyt.es>
Wed, 30 Sep 2009 16:55:21 +0000 (16:55 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Wed, 30 Sep 2009 16:55:21 +0000 (16:55 +0000)
(closes issue #15865)
 Reported by: kobaz
 Patches:
       20090915__issue15865.diff.txt uploaded by tilghman (license 14)
 Tested by: kobaz

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@221200 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index a674e0a16b67291b7452442586f37022aacab1af..48ec63bf67d01f6648264c7d80f7caf69c14af5d 100644 (file)
@@ -1980,9 +1980,9 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd)
 
 static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
 {
-       if (chan->generatordata &&  !ast_internal_timing_enabled(chan)) {
+       if (chan->generator && chan->generator->generate && chan->generatordata &&  !ast_internal_timing_enabled(chan)) {
                void *tmp = chan->generatordata;
-               int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = NULL;
+               int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = chan->generator->generate;
                int res;
                int samples;
 
@@ -2002,9 +2002,6 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram
                        samples = f->samples;
                }
 
-               if (chan->generator->generate) {
-                       generate = chan->generator->generate;
-               }
                /* This unlock is here based on two assumptions that hold true at this point in the
                 * code. 1) this function is only called from within __ast_read() and 2) all generators
                 * call ast_write() in their generate callback.