[CELT-dev] Memory leak when specifying invalid channels count

Bjoern Damstedt Rasmussen bjoern.d.rasmussen at gmail.com
Sat Jan 29 08:36:32 PST 2011


Hi

I minor issue I noticed when I passed an invalid 'channels' parameter
to celt_encoder_create() is that celt_encoder_init() doesn't free
the CELTEncoder ('st' parameter) when 'if (channels < 0 || channels > 2)'
evaluates to true.

Seems celt_encoder_init() should do like this instead:

CELTEncoder *celt_encoder_init(CELTEncoder *st, const CELTMode *mode, int
channels, int *error)
{
   if (channels < 0 || channels > 2)
   {
      if (error)
         *error = CELT_BAD_ARG;
      celt_free(st); /* ensure 'st' is deallocated */
      return NULL;
   }


Or maybe even better have celt_encoder_init() allocate the CELTEncoder so
it's only created if the input is valid.

-- Bjoern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/opus/attachments/20110129/619de4b2/attachment-0002.htm 


More information about the celt-dev mailing list