google-code-export / ffmpegthumbnailer

Automatically exported from code.google.com/p/ffmpegthumbnailer
GNU General Public License v2.0
1 stars 1 forks source link

MovieDecoder memory not released on exception #74

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
With some movie files, the call to VideoThumbnailer::generateThumbnail() throws 
an exception ('Could not find stream information'). Apparently, this exception 
comes from MovieDecoder::initialize().

I haven't really written any serious C++ code in a while but this seems to be 
problematic as MovieDecoder::initialize() may allocate a lot of memory when 
search the entire movie file for stream information. And this memory doesn't 
seem to be released when the exception is thrown.

The situation in VideoThumbnailer::generateThumbnail() is that there is a local 
object MovieDecoder that throws an exception when it is created. If a 
n exception is thrown in a local object, the object's deconstructor will not be 
called (see the attached C++ program). This is the case here and I think that's 
maybe why the MovieDecoder's memory is not released.

A possible solution might be to allocate the MovieDecoder dynamically and 
delete it explicitely on success AND when the exception was thrown.

What steps will reproduce the problem?
1. Call VideoThumbnailer::generateThumbnail() with a weird video file that 
causes the exception to be thrown in MovieDecoder::initialize().
2. For some video files this means that the entire video file will be loaded 
into memory.
3. Notice how after the exception is thrown, memory is not released.

What is the expected output? What do you see instead?

The MovieDecoder's deconstructor is called and all memory is released.

What version of the product are you using? On what operating system?

2.0.5 on Fedora 14.

Original issue reported on code.google.com by jan...@xfce.org on 5 Jan 2011 at 9:55

Attachments:

GoogleCodeExporter commented 9 years ago
Forwarded from http://bugzilla.xfce.org/show_bug.cgi?id=6999 by the way.

Original comment by jan...@xfce.org on 5 Jan 2011 at 10:07

GoogleCodeExporter commented 9 years ago
Thanks for the bug report, the behavior of the initialize functions is indeed 
incorrect. I modified it so that it calls the destroy method before throwing 
the exception. This way the memory will have been released if the method was 
called from the constructor.

I committed the fix in svn, feel free to try it out and see if the behavior 
improves. I'll make a new release if it works for you, since it's a serious 
issue.

Original comment by dirk.vdb on 6 Jan 2011 at 8:31

GoogleCodeExporter commented 9 years ago
Looks good to me. I've asked the reporters of the Xfce bug to try your commit. 
I don't think I have any video files that trigger this behaviour. But the fix 
looks good to me though.

Original comment by jan...@xfce.org on 6 Jan 2011 at 11:32

GoogleCodeExporter commented 9 years ago
One of the reporters tested your fix and it works 
(http://bugzilla.xfce.org/show_bug.cgi?id=6999#c7). Thanks for taking action so 
quickly.

Original comment by jan...@xfce.org on 6 Jan 2011 at 5:51

GoogleCodeExporter commented 9 years ago
Perfect, 2.0.6 has been released

Original comment by dirk.vdb on 6 Jan 2011 at 7:17