Help - Search - Members - Calendar
Full Version: Some bugs and leaks in foo_speex
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
Florian
I've just played a litte with the speexfile class of foo_speex and noticed one bug and some memory leaks.

Here are some possible patches for speexfile.cpp:

This patch enables reading of comments for files with only one comment field:
CODE
-641 if ( nb_fields > 1 ) {
+641 if ( nb_fields > 0 ) {


This patch fixes some memory leaks which are based on subsequent calls to ogg_stream_init in line 763:
CODE
-814 init = false;
+814 if (init) ogg_stream_clear ( &os );
     init = false;


This part is not necessary and will result in a memory leak at 656 (after applying path 1):
CODE
-592 stream[streamcount-1]->tags[stream[streamcount-1]->tagcount] = (speextags *)calloc ( 1, sizeof (speextags) );
-593 if ( stream[streamcount-1]->tags[stream[streamcount-1]->tagcount] == NULL ) {
-594      strcpy ( speex_last_error, "Memory allocation failed" );
-595      return -1;
-596 }


Memory leak fix for speexfile::stream_free_tags
CODE
-715 }
+715 if (stream[_stream]->tags[i]!=NULL)
    {
       ::free(stream[_stream]->tags[i]);
       stream[_stream]->tags[i]= NULL;
    }
  }


Case, it would be nice, if you could verify my thoughts.

~ Florian
Case
All you said is correct and patches have been added to sources. Thanks. That lib has lots of weirdness in it but I haven't had time to re-write it.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.