Skip to content

Commit

Permalink
Make sure any previously allocated FLAC stream encoder and stream dec…
Browse files Browse the repository at this point in the history
…oder

objects are deleted before a new one is allocated.
  • Loading branch information
erikd committed Jun 21, 2012
1 parent 80c47cb commit da47c11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
2012-06-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>

* src/flac.c
Make sure any previously allocated FLAC stream encoder and stream decoder
objects are deleted before a new one is allocated.

2012-06-20 Erik de Castro Lopo <erikd AT mega-nerd DOT com>

* tests/utils.tpl
Expand Down
4 changes: 4 additions & 0 deletions src/flac.c
Expand Up @@ -754,6 +754,8 @@ flac_enc_init (SF_PRIVATE *psf)
break ;
} ;

if (pflac->fse)
FLAC__stream_encoder_delete (pflac->fse) ;
if ((pflac->fse = FLAC__stream_encoder_new ()) == NULL)
return SFE_FLAC_NEW_DECODER ;

Expand Down Expand Up @@ -785,6 +787,8 @@ flac_read_header (SF_PRIVATE *psf)
{ FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;

psf_fseek (psf, 0, SEEK_SET) ;
if (pflac->fsd)
FLAC__stream_decoder_delete (pflac->fsd) ;
if ((pflac->fsd = FLAC__stream_decoder_new ()) == NULL)
return SFE_FLAC_NEW_DECODER ;

Expand Down

0 comments on commit da47c11

Please sign in to comment.