]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Check correct values in the return of ast_waitfor(); also, get rid of a
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 14 Oct 2008 20:09:06 +0000 (20:09 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 14 Oct 2008 20:09:06 +0000 (20:09 +0000)
possible memory leak.
(closes issue #13658)
 Reported by: explidous
 Patch by: me

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

apps/app_waitforsilence.c

index ef0734cdc9efec4297f1c9051706eda9deb75a2a..40435fb5c9e30efdd60187a1ad52cf4605533bda 100644 (file)
@@ -107,13 +107,13 @@ static int do_waiting(struct ast_channel *chan, int silencereqd, time_t waitstar
                res = ast_waitfor(chan, silencereqd);
 
                /* Must have gotten a hangup; let's exit */
-               if (res <= 0) {
+               if (res < 0) {
                        f = NULL;
                        break;
                }
                
                /* We waited and got no frame; sounds like digital silence or a muted digital channel */
-               if (!res) {
+               if (res == 0) {
                        dspsilence = silencereqd;
                } else {
                        /* Looks like we did get a frame, so let's check it out */
@@ -122,6 +122,8 @@ static int do_waiting(struct ast_channel *chan, int silencereqd, time_t waitstar
                                break;
                        if (f && f->frametype == AST_FRAME_VOICE) {
                                ast_dsp_silence(sildet, f, &dspsilence);
+                       }
+                       if (f) {
                                ast_frfree(f);
                        }
                }