mirror of https://github.com/axmolengine/axmol.git
issue #931: dynamically allocate array(row_pointers) in CCImage::_initWithPngData.
This commit is contained in:
parent
1b2bba06c5
commit
2bffd3a565
|
@ -290,7 +290,9 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
||||||
// read png data
|
// read png data
|
||||||
// m_nBitsPerComponent will always be 8
|
// m_nBitsPerComponent will always be 8
|
||||||
m_pData = new unsigned char[m_nWidth * m_nHeight * channels];
|
m_pData = new unsigned char[m_nWidth * m_nHeight * channels];
|
||||||
png_bytep row_pointers[m_nHeight];
|
png_bytep* row_pointers = (png_bytep*)malloc(sizeof(png_bytep)*m_nHeight);
|
||||||
|
if (row_pointers)
|
||||||
|
{
|
||||||
const unsigned int stride = m_nWidth * channels;
|
const unsigned int stride = m_nWidth * channels;
|
||||||
for (size_t i = 0; i < m_nHeight; ++i)
|
for (size_t i = 0; i < m_nHeight; ++i)
|
||||||
{
|
{
|
||||||
|
@ -298,8 +300,10 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
|
||||||
row_pointers[i] = (png_bytep)m_pData + q;
|
row_pointers[i] = (png_bytep)m_pData + q;
|
||||||
}
|
}
|
||||||
png_read_image(png_ptr, row_pointers);
|
png_read_image(png_ptr, row_pointers);
|
||||||
|
free(row_pointers);
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
}
|
||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in New Issue