]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_fax: Don't consume frames given to fax gateway on write.
authorJoshua C. Colp <jcolp@sangoma.com>
Wed, 27 May 2020 08:47:07 +0000 (05:47 -0300)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Fri, 5 Jun 2020 18:23:22 +0000 (13:23 -0500)
In a particular fax gateway scenario whereby it would
have to translate using the read translation path on a
channel the frame being translated would be consumed.
When the frame is in the write path it is not permitted
to free the frame as the caller expects it to continue
to exist.

This change makes it so that the frame is only consumed
on the read path where it is acceptable to free it.

ASTERISK-28900

Change-Id: I011c321288a1b056d92b37c85e229f4a28ee737d

res/res_fax.c

index ebb2b46266e11c6d8e779f53510d1017770949fc..b895c57ad6f011f76b38dcc71343d8dcc80b1450 100644 (file)
@@ -3568,7 +3568,7 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct
                 * translation is done, so we need to translate here */
                if ((f->frametype == AST_FRAME_VOICE) && (ast_format_cmp(f->subclass.format, ast_format_slin) != AST_FORMAT_CMP_EQUAL)
                        && (readtrans = ast_channel_readtrans(active))) {
-                       if ((f = ast_translate(readtrans, f, 1)) == NULL) {
+                       if ((f = ast_translate(readtrans, f, event == AST_FRAMEHOOK_EVENT_WRITE ? 0 : 1)) == NULL) {
                                f = &ast_null_frame;
                                return f;
                        }