From: Matthew Jordan Date: Thu, 5 Jan 2012 23:56:52 +0000 (+0000) Subject: Fix premature free'ing of the frame committed in r349608 X-Git-Tag: 10.2.0-rc1~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f8e471f1cbafb642ae76b1d69c0fb429e9e88a3;p=thirdparty%2Fasterisk.git Fix premature free'ing of the frame committed in r349608 Even though we set the frame to the ast_null_frame and return that, the caller of the frame hook may still need the frame. This now is a bit more careful about when it frees the frame, i.e., only under the same conditions that applied when we duplicated it in the first place. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@349822 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/res/res_fax.c b/res/res_fax.c index bc0eb18f8e..b9655db213 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -3058,7 +3058,11 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct * write would fail, or even if a failure would be fatal so for * now we'll just ignore the return value. */ gateway->s->tech->write(gateway->s, f); - ast_frfree(f); + if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id != AST_FORMAT_SLINEAR) && active->readtrans) { + /* Only free the frame if we translated / duplicated it - otherwise, + * let whatever is outside the frame hook do it */ + ast_frfree(f); + } f = &ast_null_frame; ao2_ref(details, -1); return f;