[haiku-bugs] Re: [Haiku] #10176: BMediaFile crashes within AVFormatReader::Sniff() if it cannot handle the file

  • From: "ttcoder" <trac@xxxxxxxxxxxx>
  • Date: Sun, 10 Nov 2013 15:56:56 -0000

#10176: BMediaFile crashes within AVFormatReader::Sniff() if it cannot handle 
the
file
------------------------------------+----------------------------
   Reporter:  ttcoder               |      Owner:  stippi
       Type:  bug                   |     Status:  assigned
   Priority:  normal                |  Milestone:  R1
  Component:  Audio & Video/Codecs  |    Version:  R1/Development
 Resolution:                        |   Keywords:  ffmpeg
 Blocked By:                        |   Blocking:
Has a Patch:  0                     |   Platform:  All
------------------------------------+----------------------------

Comment (by ttcoder):

 Good catch, reading the constructor and destructor side by side it's clear
 that the dtor should test for pointer validity!

 Otherwise just declaring the variable on the stack..
 {{{
    {
       StreamBase stream;
    }
 }}}
 ... and letting it go out of scope makes it crash!

 And even without going to that extreme, leaving it in its natural ffmpeg
 ecosystem :-) it can crash just the same, if Open() fails at any of the
 last 2 points of failure. So regardless of whether or not this ticket is
 caused by this variable mishandling, there should be a fix for it indeed:

 {{{
  StreamBase::~StreamBase()
  {
 -       av_free(fIOContext->buffer);
 +       if (fIOContext)
 +               av_free(fIOContext->buffer);
         av_free(fIOContext);
 }}}


 Tried compiling ffmpeg here but it wants to build the whole libroot.so and
 kitchen sink before doing it so maybe it would take less time to hack a
 custom jamfile, which will still take time..

 Anyway no need for somebody to check the validity of the "patch", it's
 painfully obvious it should be applied.

 I'll take it on myself of downloading a nightly once the change is
 commited and check if it fixes this ticket and report here for sure.

--
Ticket URL: <http://dev.haiku-os.org/ticket/10176#comment:5>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: