Skip to content
Permalink
Browse files

Fix a couple easy errors in animview

Errors reported by cppcheck
* undefined behaviour shifting a signed integer.
* memory leak if rnc length check fails.
  • Loading branch information...
TheCycoONE committed Jun 5, 2019
1 parent 9d7b17f commit 3b94d7ecdaff648bef5fcdf67067e0662e9acd1c
Showing with 4 additions and 3 deletions.
  1. +3 −2 AnimView/th.cpp
  2. +1 −1 AnimView/th.h
@@ -501,12 +501,13 @@ th_element_t* THAnimations::_getElement(uint32_t iListIndex)

unsigned char* THAnimations::Decompress(unsigned char* pData, size_t& iLength)
{
unsigned long outlen = rnc_output_size(pData);
unsigned char* outbuf = new unsigned char[outlen];
if (rnc_input_size(pData) != iLength) {
throw std::length_error("rnc data does not match the expected length");
}

unsigned long outlen = rnc_output_size(pData);
unsigned char* outbuf = new unsigned char[outlen];

if(rnc_unpack(pData, outbuf) == rnc_status::ok)
{
delete[] pData;
@@ -117,7 +117,7 @@ class THLayerMask
if(0 <= iLayer && iLayer < 13)
for(int iId = 0; iId < 32; ++iId)
{
if((m_iMask[iLayer] & (1 << iId)) != 0)
if((m_iMask[iLayer] & (static_cast<std::uint32_t>(1) << iId)) != 0)
return true;
}
return false;

0 comments on commit 3b94d7e

Please sign in to comment.
You can’t perform that action at this time.