diff --git a/include/share/utf8.h b/include/share/utf8.h index 6aa0e986..7d6650d6 100644 --- a/include/share/utf8.h +++ b/include/share/utf8.h @@ -19,8 +19,6 @@ * 3 : unknown encoding (but still converted, using '?') */ -void convert_set_charset(const char *charset); - int utf8_encode(const char *from, char **to); int utf8_decode(const char *from, char **to); diff --git a/src/flac/encode.c b/src/flac/encode.c index f760031a..0b0e89da 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -1500,7 +1500,7 @@ int flac__encode_flac(FILE *infile, off_t infilesize, const char *infilename, co /* (channel mask will get copied over from the source VORBIS_COMMENT if it exists) */ if(!EncoderSession_init_encoder(&encoder_session, options.common, /*channel_mask=*/0, decoder_data.metadata_blocks[0]->data.stream_info.channels, decoder_data.metadata_blocks[0]->data.stream_info.bits_per_sample, decoder_data.metadata_blocks[0]->data.stream_info.sample_rate, &decoder_data)) - return EncoderSession_finish_error(&encoder_session); + goto fubar2; /*@@@ yuck */ /* * have to wait until the FLAC encoder is set up for writing @@ -1542,12 +1542,12 @@ int flac__encode_flac(FILE *infile, off_t infilesize, const char *infilename, co retval = EncoderSession_finish_ok(&encoder_session, -1, -1); /* have to wail until encoder is completely finished before deleting because of the final step of writing the seekpoint offsets */ for(i = 0; i < decoder_data.num_metadata_blocks; i++) - free(decoder_data.metadata_blocks[i]); + FLAC__metadata_object_delete(decoder_data.metadata_blocks[i]); return retval; fubar2: for(i = 0; i < decoder_data.num_metadata_blocks; i++) - free(decoder_data.metadata_blocks[i]); + FLAC__metadata_object_delete(decoder_data.metadata_blocks[i]); fubar1: FLAC__stream_decoder_delete(decoder); return EncoderSession_finish_error(&encoder_session); diff --git a/src/share/utf8/utf8.c b/src/share/utf8/utf8.c index a77e38ba..b6f0a8ab 100644 --- a/src/share/utf8/utf8.c +++ b/src/share/utf8/utf8.c @@ -231,23 +231,17 @@ int iconvert(const char *fromcode, const char *tocode, const char *from, size_t fromlen, char **to, size_t *tolen); -static char *current_charset = 0; /* means "US-ASCII" */ - -void convert_set_charset(const char *charset) +static const char *current_charset(void) { - + const char *c = 0; #ifdef HAVE_LANGINFO_CODESET - if (!charset) - charset = nl_langinfo(CODESET); + c = nl_langinfo(CODESET); #endif - if (!charset) - charset = getenv("CHARSET"); + if (!c) + c = getenv("CHARSET"); - free(current_charset); - current_charset = 0; - if (charset && *charset) - current_charset = strdup(charset); + return c? c : "US-ASCII"; } static int convert_buffer(const char *fromcode, const char *tocode, @@ -300,20 +294,14 @@ int utf8_encode(const char *from, char **to) { char *charset; - if (!current_charset) - convert_set_charset(0); - charset = current_charset ? current_charset : "US-ASCII"; - return convert_string(charset, "UTF-8", from, to, '#'); + return convert_string(current_charset(), "UTF-8", from, to, '#'); } int utf8_decode(const char *from, char **to) { char *charset; - if (!current_charset) - convert_set_charset(0); - charset = current_charset ? current_charset : "US-ASCII"; - return convert_string("UTF-8", charset, from, to, '?'); + return convert_string("UTF-8", current_charset(), from, to, '?'); } #endif diff --git a/src/test_libFLAC++/metadata_manip.cpp b/src/test_libFLAC++/metadata_manip.cpp index c996cda8..b7506233 100644 --- a/src/test_libFLAC++/metadata_manip.cpp +++ b/src/test_libFLAC++/metadata_manip.cpp @@ -600,6 +600,8 @@ static bool generate_file_(bool include_extras, bool is_ogg) return die_("creating the encoded file"); free(vorbiscomment.data.vorbis_comment.vendor_string.entry); + free(picture.data.picture.mime_type); + free(picture.data.picture.description); free(picture.data.picture.data); return true; diff --git a/src/test_libFLAC/metadata_manip.c b/src/test_libFLAC/metadata_manip.c index 8a00235f..08c00ae1 100644 --- a/src/test_libFLAC/metadata_manip.c +++ b/src/test_libFLAC/metadata_manip.c @@ -610,6 +610,10 @@ static FLAC__bool generate_file_(FLAC__bool include_extras, FLAC__bool is_ogg) free(vorbiscomment.data.vorbis_comment.vendor_string.entry); free(picture.data.picture.mime_type); + free(picture.data.picture.description); + free(picture.data.picture.data); + if(!include_extras) + FLAC__metadata_object_delete(cuesheet); return true; } diff --git a/src/test_seeking/main.c b/src/test_seeking/main.c index 3bc0db47..1ea18ed4 100644 --- a/src/test_seeking/main.c +++ b/src/test_seeking/main.c @@ -304,6 +304,7 @@ static FLAC__bool seek_barrage(FLAC__bool is_ogg, const char *filename, off_t fi return die_s_("FLAC__stream_decoder_finish() FAILED", decoder); } + FLAC__stream_decoder_delete(decoder); printf("\nPASSED!\n"); return true;