[FFmpeg-devel] [PATCH] flacdec: fix memleaks

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Jul 29 18:32:01 CEST 2012


On Sun, Jul 29, 2012 at 04:15:10PM +0000, Paul B Mahol wrote:
> On 7/29/12, Reimar Doeffinger <Reimar.Doeffinger at gmx.de> wrote:
> > On Sun, Jul 29, 2012 at 03:36:28PM +0000, Paul B Mahol wrote:
> >> On 7/29/12, Reimar Doeffinger <Reimar.Doeffinger at gmx.de> wrote:
> >> > On Sun, Jul 29, 2012 at 02:14:12PM +0000, Paul B Mahol wrote:
> >> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> >> >
> >> > Thanks, but could you please use goto instead?
> >> > This is quite a lot of code duplication, and if someone e.g. adds a
> >> > second
> >> > buffer that needs to be freed there's a good chance they'll miss to add
> >> > it at some places.
> >>
> >> Use goto only for this specific case or for all cases?
> >
> > Not sure I understand the question.
> > Ideally IMHO all functions that need something freed should have at most
> > two return statements: one for the success and one for the failure case.
> > goto usually is the most convenient way of achieving that.
> 
> I prefer to fix memleak in one patch and do refactoring in another.

I don't see any point in that, since the refactoring will just happen to
fix the memleaks as a side-effect, see attached untested patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: leakfix.diff
Type: text/x-diff
Size: 3656 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120729/5b6b9c30/attachment.bin>


More information about the ffmpeg-devel mailing list