diff --git a/ASTCEncoder/src/Decompressor.cpp b/ASTCEncoder/src/Decompressor.cpp index ced4592..f85f0cc 100644 --- a/ASTCEncoder/src/Decompressor.cpp +++ b/ASTCEncoder/src/Decompressor.cpp @@ -820,7 +820,7 @@ namespace ASTCC { // Determine partitions, partition index, and color endpoint modes int32 planeIdx = -1; - uint32 partitionIndex = nPartitions; + uint32 partitionIndex; uint32 colorEndpointMode[4] = {0, 0, 0, 0}; // Define color data. diff --git a/Base/include/FasTC/ScopedAllocator.h b/Base/include/FasTC/ScopedAllocator.h index 1696b02..34e4c5d 100644 --- a/Base/include/FasTC/ScopedAllocator.h +++ b/Base/include/FasTC/ScopedAllocator.h @@ -71,7 +71,7 @@ namespace FasTC { ~ScopedAllocator() { if(m_Ptr) { - delete m_Ptr; + delete [] m_Ptr; m_Ptr = NULL; } } diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index 86e1db5..8700517 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -552,6 +552,9 @@ template class Image; void GenerateGaussianKernel(Image &out, uint32 size, float sigma) { assert(size % 2); + if (size == 0) { + return; + } out = Image(size, size); if(size == 1) { diff --git a/ETCEncoder/src/rg_etc1.cpp b/ETCEncoder/src/rg_etc1.cpp index 98d249d..bef50f3 100755 --- a/ETCEncoder/src/rg_etc1.cpp +++ b/ETCEncoder/src/rg_etc1.cpp @@ -1811,7 +1811,7 @@ namespace rg_etc1 { 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) continue; } @@ -1825,7 +1825,7 @@ namespace rg_etc1 { 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) continue; } diff --git a/IO/src/ImageLoaderPNG.cpp b/IO/src/ImageLoaderPNG.cpp index 8365a40..759d693 100644 --- a/IO/src/ImageLoaderPNG.cpp +++ b/IO/src/ImageLoaderPNG.cpp @@ -140,6 +140,7 @@ bool ImageLoaderPNG::ReadData() { default: ReportError("PNG color type unsupported"); png_destroy_read_struct(&png_ptr, NULL, NULL); + delete [] rowData; return false; case PNG_COLOR_TYPE_PALETTE: diff --git a/IO/src/ImageWriterKTX.cpp b/IO/src/ImageWriterKTX.cpp index f54fe5f..4fe2244 100644 --- a/IO/src/ImageWriterKTX.cpp +++ b/IO/src/ImageWriterKTX.cpp @@ -86,7 +86,7 @@ class ByteWriter { m_BufferSz <<= 1; uint8 *newBuffer = new uint8[m_BufferSz]; memcpy(newBuffer, m_Base, m_BytesWritten); - delete m_Base; + delete [] m_Base; m_Base = newBuffer; m_Head = m_Base + m_BytesWritten; } @@ -138,6 +138,8 @@ bool ImageWriterKTX::WriteImage() { default: fprintf(stderr, "Unsupported KTX compressed format: %d\n", ci->GetFormat()); + m_RawFileData = wtr.GetBytes(); + m_RawFileDataSz = wtr.GetBytesWritten(); return false; } } else { diff --git a/IO/src/ImageWriterPNG.cpp b/IO/src/ImageWriterPNG.cpp index 04045ac..4b3fd0a 100644 --- a/IO/src/ImageWriterPNG.cpp +++ b/IO/src/ImageWriterPNG.cpp @@ -71,7 +71,7 @@ public: uint8 *newData = new uint8[writer.m_RawFileDataSz << 1]; memcpy(newData, writer.m_RawFileData, writer.m_RawFileDataSz); writer.m_RawFileDataSz <<= 1; - delete writer.m_RawFileData; + delete [] writer.m_RawFileData; writer.m_RawFileData = newData; } diff --git a/IO/third_party/tga/targa.c b/IO/third_party/tga/targa.c index 04f0a7c..6c923e5 100755 --- a/IO/third_party/tga/targa.c +++ b/IO/third_party/tga/targa.c @@ -479,8 +479,7 @@ int targa_loadFromData(Targa *targa, const unsigned char *data, int dataLength) } else { // RLE image ii = 0; - nn = 0; - rleId = 0; + nn = 0; colorMode = (bitLength / 8); length = (targa->width * targa->height); while(ii < length) {