[asterisk-dev] [Code Review] Change cleanup ordering in filestream destructor.

Russell Bryant reviewboard at asterisk.org
Wed Jan 23 15:59:02 CST 2013

This is an automatically generated e-mail. To reply, visit:

Review request for Asterisk Developers and Leif Madsen.


This patch came about due to a problem observed where wav files had an
empty header.  The header is supposed to be updated in wav_write().  It
turns out that this was broken when the cache_record_files option from
asterisk.conf was enabled.  The cleanup code was moving the file to its
final destination *before* running the close() method of the file
destructor, so the header didn't get updated.

Another problem here is that the move was being done before actually
closing the FILE *.

Finally, the last bug fixed here is that I noticed that wav_close()
checks for stream->filename to be non-NULL.  In the previous cleanup
order, it's checking a pointer to freed memory.  This doesn't actually
cause anything to break, but it's treading on dangerous waters.  Now the
free() of stream->filename is happening after the format module's
close() method gets called, so it's safer.


  /branches/1.8/main/file.c 380022 

Diff: https://reviewboard.asterisk.org/r/2286/diff


Problem reported by Leif Madsen.  He confirmed that this patch fixed his issue.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130123/e7d771f0/attachment.htm>

More information about the asterisk-dev mailing list