mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 00:24:05 +00:00
res_agi.c: Prevent possible double free during SPEECH RECOGNIZE
When using the speech recognition module, crashes can occur
sporadically due to a "double free or corruption (out)" error. Now, in
the section where the audio stream is being captured in a loop, each
time after releasing fr, it is set to NULL to prevent repeated
deallocation.
Fixes #772
(cherry picked from commit 2d676c7560
)
This commit is contained in:
committed by
Asterisk Development Team
parent
c1df33a717
commit
f7b9575241
@@ -3650,8 +3650,10 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
|
|||||||
time(¤t);
|
time(¤t);
|
||||||
if ((current - start) >= timeout) {
|
if ((current - start) >= timeout) {
|
||||||
reason = "timeout";
|
reason = "timeout";
|
||||||
if (fr)
|
if (fr) {
|
||||||
ast_frfree(fr);
|
ast_frfree(fr);
|
||||||
|
fr = NULL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3708,6 +3710,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
|
|||||||
reason = "hangup";
|
reason = "hangup";
|
||||||
}
|
}
|
||||||
ast_frfree(fr);
|
ast_frfree(fr);
|
||||||
|
fr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user