mirror of https://github.com/xiph/flac
Check return code of static_metadata_append()
Fix crash due to ignored memory allocation error in static_metadata_append().
This commit is contained in:
parent
4469640b95
commit
0adaa03498
|
@ -1941,10 +1941,12 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
|
|||
|
||||
if(e->seek_table_template->data.seek_table.num_points > 0) {
|
||||
e->seek_table_template->is_last = false; /* the encoder will set this for us */
|
||||
static_metadata_append(&static_metadata, e->seek_table_template, /*needs_delete=*/false);
|
||||
if(!static_metadata_append(&static_metadata, e->seek_table_template, /*needs_delete=*/false))
|
||||
return false;
|
||||
}
|
||||
if(0 != static_metadata.cuesheet)
|
||||
static_metadata_append(&static_metadata, static_metadata.cuesheet, /*needs_delete=*/false);
|
||||
if(!static_metadata_append(&static_metadata, static_metadata.cuesheet, /*needs_delete=*/false))
|
||||
return false;
|
||||
if(e->info.channel_mask) {
|
||||
options.vorbis_comment_with_channel_mask_tag = FLAC__metadata_object_clone(options.vorbis_comment);
|
||||
if(!flac__utils_set_channel_mask_tag(options.vorbis_comment_with_channel_mask_tag, e->info.channel_mask)) {
|
||||
|
@ -1952,12 +1954,15 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
|
|||
static_metadata_clear(&static_metadata);
|
||||
return false;
|
||||
}
|
||||
static_metadata_append(&static_metadata, options.vorbis_comment_with_channel_mask_tag, /*needs_delete=*/true);
|
||||
if(!static_metadata_append(&static_metadata, options.vorbis_comment_with_channel_mask_tag, /*needs_delete=*/true))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
static_metadata_append(&static_metadata, options.vorbis_comment, /*needs_delete=*/false);
|
||||
if(!static_metadata_append(&static_metadata, options.vorbis_comment, /*needs_delete=*/false))
|
||||
return false;
|
||||
for(i = 0; i < options.num_pictures; i++)
|
||||
static_metadata_append(&static_metadata, options.pictures[i], /*needs_delete=*/false);
|
||||
if(!static_metadata_append(&static_metadata, options.pictures[i], /*needs_delete=*/false))
|
||||
return false;
|
||||
if(foreign_metadata) {
|
||||
for(i = 0; i < foreign_metadata->num_blocks; i++) {
|
||||
FLAC__StreamMetadata *p = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING);
|
||||
|
@ -1966,7 +1971,8 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
|
|||
static_metadata_clear(&static_metadata);
|
||||
return false;
|
||||
}
|
||||
static_metadata_append(&static_metadata, p, /*needs_delete=*/true);
|
||||
if(!static_metadata_append(&static_metadata, p, /*needs_delete=*/true))
|
||||
return false;
|
||||
static_metadata.metadata[static_metadata.num_metadata-1]->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8 + foreign_metadata->blocks[i].size;
|
||||
}
|
||||
}
|
||||
|
@ -1978,7 +1984,8 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
|
|||
else
|
||||
padding.length = (uint32_t)(options.padding>0? options.padding : (e->total_samples_to_encode / sample_rate < 20*60? FLAC_ENCODE__DEFAULT_PADDING : FLAC_ENCODE__DEFAULT_PADDING*8)) + (e->replay_gain ? GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED : 0);
|
||||
padding.length = min(padding.length, (1u << FLAC__STREAM_METADATA_LENGTH_LEN) - 1);
|
||||
static_metadata_append(&static_metadata, &padding, /*needs_delete=*/false);
|
||||
if(!static_metadata_append(&static_metadata, &padding, /*needs_delete=*/false))
|
||||
return false;
|
||||
}
|
||||
metadata = static_metadata.metadata;
|
||||
num_metadata = static_metadata.num_metadata;
|
||||
|
|
Loading…
Reference in New Issue