Hi, We are using the libFLAC++ library to encode FLAC files with Vorbis comments in them and have had the FLAC 1.1.2 version fail consistently (access violation or segmentation fault) on both Windows and Linux. We tracked this down to the metadata code in the C++ API.
The problem is in src/libFLAC++/file_encoder.cpp. There are two problems - firstly, a C-style cast is hiding a bad conversion from the pointer to a C++ object to the C API's struct for metadata and secondly, the method uses an array internal to the method to set the metadata using the C API. I have attached some test code which causes the problem. The underlying problem is that the set_metadata calls don't keep a copy of the metadata information, even though it is not read (and written to the stream) until the init call. However the objects inside the array must also remain valid (this is the library user's responsibility) so I also added a note in the header documentation. I have attached a patch to fix the cast problem, and also to make the C++ API hold onto its array of metadata blocks (but not copied). This avoids changing the C library behaviour, though I would think it better to have the metadata blocks copied upon the set_metadata call (ie, in src/libFLAC/stream_encoder.c) instead. Also note that I have only changed the file_decoder, a corresponding problem seems to exist in the code for seekable_stream_encoder/stream_encoder as well. Thanks, Joshua King Defence Science and Technology Organisation Tel: (08) 9553 4305 IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the Crimes Act 1914. If you have received this email in error, you are requested to contact the sender and delete the email.
flac-set-metadata-fix.patch
Description: flac-set-metadata-fix.patch
test.cpp
Description: test.cpp
_______________________________________________ Flac-dev mailing list [email protected] http://lists.xiph.org/mailman/listinfo/flac-dev
