Commit 8c24ab3a authored by Josh Coalson's avatar Josh Coalson
Browse files

fix tiny bug with filename setting

parent 29516967
......@@ -95,7 +95,7 @@ void FLAC__file_decoder_delete(FLAC__FileDecoder *);
* NOT reset the values to the constructor defaults.
*/
FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder, FLAC__bool value);
FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value);
FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value); /* 'value' may not be 0; use "-" for stdin */
FLAC__bool FLAC__file_decoder_set_write_callback(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderWriteStatus (*value)(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data));
FLAC__bool FLAC__file_decoder_set_metadata_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, const FLAC__StreamMetaData *metadata, void *client_data));
FLAC__bool FLAC__file_decoder_set_error_callback(const FLAC__FileDecoder *decoder, void (*value)(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data));
......
......@@ -154,7 +154,7 @@ FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder)
decoder->private_->stream_decoder = 0;
decoder->private_->seek_table = 0;
if(0 == strcmp(decoder->private_->filename, "-"))
if(0 == decoder->private_->filename)
decoder->private_->file = stdin;
else
decoder->private_->file = fopen(decoder->private_->filename, "rb");
......@@ -221,13 +221,21 @@ FLAC__bool FLAC__file_decoder_set_md5_checking(const FLAC__FileDecoder *decoder,
FLAC__bool FLAC__file_decoder_set_filename(const FLAC__FileDecoder *decoder, const char *value)
{
FLAC__ASSERT(value != 0);
if(decoder->protected_->state != FLAC__FILE_DECODER_UNINITIALIZED)
return false;
if(0 == (decoder->private_->filename = (char*)malloc(strlen(value)+1))) {
decoder->protected_->state = FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
if(0 != decoder->private_->filename)
free(decoder->private_->filename);
if(0 == strcmp(value, "-")) {
decoder->private_->filename = 0;
}
else {
if(0 == (decoder->private_->filename = (char*)malloc(strlen(value)+1))) {
decoder->protected_->state = FLAC__FILE_DECODER_MEMORY_ALLOCATION_ERROR;
return false;
}
strcpy(decoder->private_->filename, value);
}
strcpy(decoder->private_->filename, value);
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment