Fix a few errors caught by static analysis

This commit is contained in:
Pavel Krajcevski 2015-12-20 15:17:54 -05:00
parent 7cf9038505
commit 8a1906e7b7
8 changed files with 13 additions and 8 deletions

View file

@ -820,7 +820,7 @@ namespace ASTCC {
// Determine partitions, partition index, and color endpoint modes // Determine partitions, partition index, and color endpoint modes
int32 planeIdx = -1; int32 planeIdx = -1;
uint32 partitionIndex = nPartitions; uint32 partitionIndex;
uint32 colorEndpointMode[4] = {0, 0, 0, 0}; uint32 colorEndpointMode[4] = {0, 0, 0, 0};
// Define color data. // Define color data.

View file

@ -71,7 +71,7 @@ namespace FasTC {
~ScopedAllocator() { ~ScopedAllocator() {
if(m_Ptr) { if(m_Ptr) {
delete m_Ptr; delete [] m_Ptr;
m_Ptr = NULL; m_Ptr = NULL;
} }
} }

View file

@ -552,6 +552,9 @@ template class Image<Color>;
void GenerateGaussianKernel(Image<IPixel> &out, uint32 size, float sigma) { void GenerateGaussianKernel(Image<IPixel> &out, uint32 size, float sigma) {
assert(size % 2); assert(size % 2);
if (size == 0) {
return;
}
out = Image<IPixel>(size, size); out = Image<IPixel>(size, size);
if(size == 1) { if(size == 1) {

View file

@ -1811,7 +1811,7 @@ namespace rg_etc1
{ {
if (block_inten[0] > m_pSorted_luma[n - 1]) if (block_inten[0] > m_pSorted_luma[n - 1])
{ {
const uint min_error = labs(block_inten[0] - m_pSorted_luma[n - 1]); const uint min_error = block_inten[0] - m_pSorted_luma[n - 1];
if (min_error >= trial_solution.m_error) if (min_error >= trial_solution.m_error)
continue; continue;
} }
@ -1825,7 +1825,7 @@ namespace rg_etc1
{ {
if (m_pSorted_luma[0] > block_inten[3]) if (m_pSorted_luma[0] > block_inten[3])
{ {
const uint min_error = labs(m_pSorted_luma[0] - block_inten[3]); const uint min_error = m_pSorted_luma[0] - block_inten[3];
if (min_error >= trial_solution.m_error) if (min_error >= trial_solution.m_error)
continue; continue;
} }

View file

@ -140,6 +140,7 @@ bool ImageLoaderPNG::ReadData() {
default: default:
ReportError("PNG color type unsupported"); ReportError("PNG color type unsupported");
png_destroy_read_struct(&png_ptr, NULL, NULL); png_destroy_read_struct(&png_ptr, NULL, NULL);
delete [] rowData;
return false; return false;
case PNG_COLOR_TYPE_PALETTE: case PNG_COLOR_TYPE_PALETTE:

View file

@ -86,7 +86,7 @@ class ByteWriter {
m_BufferSz <<= 1; m_BufferSz <<= 1;
uint8 *newBuffer = new uint8[m_BufferSz]; uint8 *newBuffer = new uint8[m_BufferSz];
memcpy(newBuffer, m_Base, m_BytesWritten); memcpy(newBuffer, m_Base, m_BytesWritten);
delete m_Base; delete [] m_Base;
m_Base = newBuffer; m_Base = newBuffer;
m_Head = m_Base + m_BytesWritten; m_Head = m_Base + m_BytesWritten;
} }
@ -138,6 +138,8 @@ bool ImageWriterKTX::WriteImage() {
default: default:
fprintf(stderr, "Unsupported KTX compressed format: %d\n", ci->GetFormat()); fprintf(stderr, "Unsupported KTX compressed format: %d\n", ci->GetFormat());
m_RawFileData = wtr.GetBytes();
m_RawFileDataSz = wtr.GetBytesWritten();
return false; return false;
} }
} else { } else {

View file

@ -71,7 +71,7 @@ public:
uint8 *newData = new uint8[writer.m_RawFileDataSz << 1]; uint8 *newData = new uint8[writer.m_RawFileDataSz << 1];
memcpy(newData, writer.m_RawFileData, writer.m_RawFileDataSz); memcpy(newData, writer.m_RawFileData, writer.m_RawFileDataSz);
writer.m_RawFileDataSz <<= 1; writer.m_RawFileDataSz <<= 1;
delete writer.m_RawFileData; delete [] writer.m_RawFileData;
writer.m_RawFileData = newData; writer.m_RawFileData = newData;
} }

View file

@ -480,7 +480,6 @@ int targa_loadFromData(Targa *targa, const unsigned char *data, int dataLength)
else { // RLE image else { // RLE image
ii = 0; ii = 0;
nn = 0; nn = 0;
rleId = 0;
colorMode = (bitLength / 8); colorMode = (bitLength / 8);
length = (targa->width * targa->height); length = (targa->width * targa->height);
while(ii < length) { while(ii < length) {