mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
Coverity fixes
Signed-off-by: Felipe Contreras <felipe.contreras@nokia.com>
This commit is contained in:
committed by
David Schleef
parent
c2593cc1bd
commit
6c8d740c1a
@@ -259,7 +259,7 @@ void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
|
||||
|
||||
byteSwap(ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
|
||||
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
|
||||
if(0 != ctx->internal_buf) {
|
||||
free(ctx->internal_buf);
|
||||
ctx->internal_buf = 0;
|
||||
@@ -408,7 +408,8 @@ FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const
|
||||
if(0 == (ctx->internal_buf = (FLAC__byte*)safe_malloc_(bytes_needed)))
|
||||
return false;
|
||||
}
|
||||
ctx->internal_buf = tmp;
|
||||
else
|
||||
ctx->internal_buf = tmp;
|
||||
ctx->capacity = bytes_needed;
|
||||
}
|
||||
|
||||
|
||||
@@ -1217,6 +1217,7 @@ static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle han
|
||||
}
|
||||
|
||||
if(!read_metadata_block_header_cb_(handle, read_cb, &is_last, &type, &length)) {
|
||||
node_delete_(node);
|
||||
chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR;
|
||||
return false;
|
||||
}
|
||||
@@ -1411,38 +1412,34 @@ static FLAC__bool chain_rewrite_file_(FLAC__Metadata_Chain *chain, const char *t
|
||||
}
|
||||
if(!open_tempfile_(chain->filename, tempfile_path_prefix, &tempfile, &tempfilename, &status)) {
|
||||
chain->status = get_equivalent_status_(status);
|
||||
cleanup_tempfile_(&tempfile, &tempfilename);
|
||||
return false;
|
||||
goto err;
|
||||
}
|
||||
if(!copy_n_bytes_from_file_(f, tempfile, chain->first_offset, &status)) {
|
||||
chain->status = get_equivalent_status_(status);
|
||||
cleanup_tempfile_(&tempfile, &tempfilename);
|
||||
return false;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* write the metadata */
|
||||
for(node = chain->head; node; node = node->next) {
|
||||
if(!write_metadata_block_header_(tempfile, &status, node->data)) {
|
||||
chain->status = get_equivalent_status_(status);
|
||||
return false;
|
||||
goto err;
|
||||
}
|
||||
if(!write_metadata_block_data_(tempfile, &status, node->data)) {
|
||||
chain->status = get_equivalent_status_(status);
|
||||
return false;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
/*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/
|
||||
|
||||
/* copy the file postfix (everything after the metadata) */
|
||||
if(0 != fseeko(f, chain->last_offset, SEEK_SET)) {
|
||||
cleanup_tempfile_(&tempfile, &tempfilename);
|
||||
chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
|
||||
return false;
|
||||
goto err;
|
||||
}
|
||||
if(!copy_remaining_bytes_from_file_(f, tempfile, &status)) {
|
||||
cleanup_tempfile_(&tempfile, &tempfilename);
|
||||
chain->status = get_equivalent_status_(status);
|
||||
return false;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* move the tempfile on top of the original */
|
||||
@@ -1451,6 +1448,11 @@ static FLAC__bool chain_rewrite_file_(FLAC__Metadata_Chain *chain, const char *t
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
err:
|
||||
(void)fclose(f);
|
||||
cleanup_tempfile_(&tempfile, &tempfilename);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* assumes 'handle' is already at beginning of file */
|
||||
|
||||
Reference in New Issue
Block a user