summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
authorAaron Brashears <aaronb@lindenlab.com>2007-02-02 17:28:58 +0000
committerAaron Brashears <aaronb@lindenlab.com>2007-02-02 17:28:58 +0000
commit305c74d5163c5e344a675d39ca2394a9e45bd2c2 (patch)
tree42836c4a6010b2b015156024d3cfb6bf64a48ad6 /indra/llimage
parent54d89549df38bb61881583a3eb8d3645c107d79f (diff)
Result of svn merge -r57264:57370 svn+ssh://svn/svn/linden/branches/adroit.r40-68 into release.
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp56
-rw-r--r--indra/llimage/llimagebmp.cpp20
-rw-r--r--indra/llimage/llimagedxt.cpp15
-rw-r--r--indra/llimage/llimagejpeg.cpp11
-rw-r--r--indra/llimage/llimagetga.cpp15
5 files changed, 82 insertions, 35 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 89b4a6d1cc..dc864aaf53 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -148,7 +148,7 @@ U8* LLImageBase::reallocateData(S32 size)
if (mData)
{
S32 bytes = llmin(mDataSize, size);
- memcpy(new_datap, mData, bytes);
+ memcpy(new_datap, mData, bytes); /* Flawfinder: ignore */
delete[] mData;
}
mData = new_datap;
@@ -245,7 +245,11 @@ BOOL LLImageRaw::copyData(U8 *data, U16 width, U16 height, S8 components)
{
return FALSE;
}
- memcpy(getData(), data, width*height*components);
+ if (getData() == NULL || data == NULL)
+ {
+ return FALSE;
+ }
+ memcpy(getData(), data, width*height*components); /* Flawfinder: ignore */
return TRUE;
}
@@ -269,11 +273,16 @@ U8 * LLImageRaw::getSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height) const
U8 *data = new U8[width*height*getComponents()];
// Should do some simple bounds checking
+ if (!data)
+ {
+ llerrs << "Out of memory in LLImageRaw::getSubImage" << llendl;
+ return NULL;
+ }
U32 i;
for (i = y_pos; i < y_pos+height; i++)
{
- memcpy(data + i*width*getComponents(),
+ memcpy(data + i*width*getComponents(), /* Flawfinder: ignore */
getData() + ((y_pos + i)*getWidth() + x_pos)*getComponents(), getComponents()*width);
}
return data;
@@ -309,7 +318,7 @@ BOOL LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height,
{
from_offset = i*width*getComponents();
}
- memcpy(getData() + to_offset*getComponents(),
+ memcpy(getData() + to_offset*getComponents(), /* Flawfinder: ignore */
data + from_offset, getComponents()*width);
}
}
@@ -326,7 +335,7 @@ BOOL LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height,
{
from_offset = (height - 1 - i)*width*getComponents();
}
- memcpy(getData() + to_offset*getComponents(),
+ memcpy(getData() + to_offset*getComponents(), /* Flawfinder: ignore */
data + from_offset, getComponents()*width);
}
}
@@ -373,14 +382,19 @@ void LLImageRaw::verticalFlip()
LLMemType mt1((LLMemType::EMemType)mMemType);
S32 row_bytes = getWidth() * getComponents();
U8* line_buffer = new U8[row_bytes];
+ if (!line_buffer )
+ {
+ llerrs << "Out of memory in LLImageRaw::verticalFlip()" << llendl;
+ return;
+ }
S32 mid_row = getHeight() / 2;
for( S32 row = 0; row < mid_row; row++ )
{
U8* row_a_data = getData() + row * row_bytes;
U8* row_b_data = getData() + (getHeight() - 1 - row) * row_bytes;
- memcpy( line_buffer, row_a_data, row_bytes );
- memcpy( row_a_data, row_b_data, row_bytes );
- memcpy( row_b_data, line_buffer, row_bytes );
+ memcpy( line_buffer, row_a_data, row_bytes ); /* Flawfinder: ignore */
+ memcpy( row_a_data, row_b_data, row_bytes ); /* Flawfinder: ignore */
+ memcpy( row_b_data, line_buffer, row_bytes ); /* Flawfinder: ignore */
}
delete[] line_buffer;
}
@@ -672,7 +686,7 @@ void LLImageRaw::copyUnscaled(LLImageRaw* src)
llassert( src->getComponents() == dst->getComponents() );
llassert( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) );
- memcpy( dst->getData(), src->getData(), getWidth() * getHeight() * getComponents() );
+ memcpy( dst->getData(), src->getData(), getWidth() * getHeight() * getComponents() ); /* Flawfinder: ignore */
}
@@ -756,7 +770,7 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
if( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) )
{
- memcpy( dst->getData(), src->getData(), getWidth() * getHeight() * getComponents() );
+ memcpy( dst->getData(), src->getData(), getWidth() * getHeight() * getComponents() ); /* Flawfinder: ignore */
return;
}
@@ -822,7 +836,12 @@ void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
// copy out existing image data
S32 temp_data_size = old_width * old_height * getComponents();
U8* temp_buffer = new U8[ temp_data_size ];
- memcpy(temp_buffer, getData(), temp_data_size);
+ if (!temp_buffer)
+ {
+ llerrs << "Out of memory in LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )" << llendl;
+ return;
+ }
+ memcpy(temp_buffer, getData(), temp_data_size); /* Flawfinder: ignore */
// allocate new image data, will delete old data
U8* new_buffer = allocateDataSize(new_width, new_height, getComponents());
@@ -831,7 +850,7 @@ void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
{
if (row < old_height)
{
- memcpy(new_buffer + (new_width * row * getComponents()), temp_buffer + (old_width * row * getComponents()), getComponents() * llmin(old_width, new_width));
+ memcpy(new_buffer + (new_width * row * getComponents()), temp_buffer + (old_width * row * getComponents()), getComponents() * llmin(old_width, new_width)); /* Flawfinder: ignore */
if (old_width < new_width)
{
// pad out rest of row with black
@@ -1185,7 +1204,7 @@ bool LLImageRaw::createFromFile(const LLString &filename, bool j2c_lowest_mip_on
llassert(image.notNull());
U8 *buffer = image->allocateData(length);
- ifs.read ((char*)buffer, length);
+ ifs.read ((char*)buffer, length); /* Flawfinder: ignore */
ifs.close();
image->updateData();
@@ -1534,7 +1553,7 @@ BOOL LLImageFormatted::copyData(U8 *data, S32 size)
{
deleteData();
allocateData(size);
- memcpy(getData(), data, size);
+ memcpy(getData(), data, size); /* Flawfinder: ignore */
}
updateData(); // virtual
@@ -1548,15 +1567,20 @@ BOOL LLImageFormatted::appendData(U8 *data, S32 size)
U8* old_data = getData();
S32 new_size = old_size + size;
U8* new_data = new U8[new_size];
+ if (!new_data)
+ {
+ llerrs << "Out of memory in LLImageFormatted::appendData(U8 *data, S32 size)" << llendl;
+ return FALSE;
+ }
// resize the image
setDataAndSize(new_data, new_size);
// copy the old data and delete it
- memcpy(new_data, old_data, old_size);
+ memcpy(new_data, old_data, old_size); /* Flawfinder: ignore */
delete old_data;
// if we have new data, copy it and call updateData()
if (data)
{
- memcpy(new_data + old_size, data, size);
+ memcpy(new_data + old_size, data, size); /* Flawfinder: ignore */
updateData(); // virtual
}
return TRUE;
diff --git a/indra/llimage/llimagebmp.cpp b/indra/llimage/llimagebmp.cpp
index 94aaa5c19e..cca7443ba4 100644
--- a/indra/llimage/llimagebmp.cpp
+++ b/indra/llimage/llimagebmp.cpp
@@ -123,7 +123,10 @@ BOOL LLImageBMP::updateData()
LLBMPHeader header;
llassert( sizeof( header ) == BITMAP_HEADER_SIZE );
- memcpy((void *)&header, mdata + FILE_HEADER_SIZE, BITMAP_HEADER_SIZE);
+ memcpy( /* Flawfinder: ignore */
+ (void*)&header,
+ mdata + FILE_HEADER_SIZE,
+ BITMAP_HEADER_SIZE);
// convert BMP header from little endian (no-op on little endian builds)
llendianswizzleone(header.mSize);
@@ -257,7 +260,7 @@ BOOL LLImageBMP::updateData()
extension_size = 4 * 3;
- memcpy( mBitfieldMask, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE, extension_size);
+ memcpy( mBitfieldMask, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE, extension_size); /* Flawfinder: ignore */
}
else
if( windows_95_version )
@@ -266,11 +269,11 @@ BOOL LLImageBMP::updateData()
extension_size = sizeof( win_95_extension );
llassert( sizeof( win_95_extension ) + BITMAP_HEADER_SIZE == 108 );
- memcpy( &win_95_extension, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE, sizeof( win_95_extension ) );
+ memcpy( &win_95_extension, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE, sizeof( win_95_extension ) ); /* Flawfinder: ignore */
if( 3 == header.mCompression )
{
- memcpy( mBitfieldMask, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE, 4 * 4);
+ memcpy( mBitfieldMask, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE, 4 * 4); /* Flawfinder: ignore */
}
// Color correction ignored for now
@@ -298,7 +301,12 @@ BOOL LLImageBMP::updateData()
if( 0 != mColorPaletteColors )
{
mColorPalette = new U8[color_palette_size];
- memcpy( mColorPalette, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE + extension_size, color_palette_size );
+ if (!mColorPalette)
+ {
+ llerrs << "Out of memory in LLImageBMP::updateData()" << llendl;
+ return FALSE;
+ }
+ memcpy( mColorPalette, mdata + FILE_HEADER_SIZE + BITMAP_HEADER_SIZE + extension_size, color_palette_size ); /* Flawfinder: ignore */
}
return TRUE;
@@ -568,7 +576,7 @@ BOOL LLImageBMP::encode(const LLImageRaw* raw_image, F32 encode_time)
U32 cur_pos = 0;
memcpy(mdata, magic, 14);
cur_pos += 14;
- memcpy(mdata+cur_pos, &header, 40);
+ memcpy(mdata+cur_pos, &header, 40); /* Flawfinder: ignore */
cur_pos += 40;
if (getComponents() == 1)
{
diff --git a/indra/llimage/llimagedxt.cpp b/indra/llimage/llimagedxt.cpp
index 9ddd044007..dfb5b957d3 100644
--- a/indra/llimage/llimagedxt.cpp
+++ b/indra/llimage/llimagedxt.cpp
@@ -260,7 +260,7 @@ BOOL LLImageDXT::decode(LLImageRaw* raw_image, F32 time)
}
raw_image->resize(width, height, ncomponents);
- memcpy(raw_image->getData(), data, image_size);
+ memcpy(raw_image->getData(), data, image_size); /* Flawfinder: ignore */
return TRUE;
}
@@ -354,7 +354,7 @@ BOOL LLImageDXT::encode(const LLImageRaw* raw_image, F32 time, bool explicit_mip
S32 bytes = formatBytes(format, w, h);
if (mip==0)
{
- memcpy(mipdata, raw_image->getData(), bytes);
+ memcpy(mipdata, raw_image->getData(), bytes); /* Flawfinder: ignore */
}
else if (explicit_mips)
{
@@ -406,15 +406,20 @@ bool LLImageDXT::convertToDXR()
S32 total_bytes = getDataSize();
U8* olddata = getData();
U8* newdata = new U8[total_bytes];
+ if (!newdata)
+ {
+ llerrs << "Out of memory in LLImageDXT::convertToDXR()" << llendl;
+ return false;
+ }
llassert(total_bytes > 0);
memset(newdata, 0, total_bytes);
- memcpy(newdata, olddata, mHeaderSize);
+ memcpy(newdata, olddata, mHeaderSize); /* Flawfinder: ignore */
for (S32 mip=0; mip<nmips; mip++)
{
S32 bytes = formatBytes(mFileFormat, width, height);
S32 newoffset = getMipOffset(mip);
S32 oldoffset = mHeaderSize + (total_bytes - newoffset - bytes);
- memcpy(newdata + newoffset, olddata + oldoffset, bytes);
+ memcpy(newdata + newoffset, olddata + oldoffset, bytes); /* Flawfinder: ignore */
width >>= 1;
height >>= 1;
}
@@ -468,7 +473,7 @@ void LLImageDXT::extractMip(const U8 *indata, U8* mipdata, int width, int height
for (int h=0;h<mip_height;++h)
{
int start_offset = initial_offset + line_width * h + line_offset;
- memcpy(mipdata + mip_line_width*h, indata + start_offset, mip_line_width);
+ memcpy(mipdata + mip_line_width*h, indata + start_offset, mip_line_width); /* Flawfinder: ignore */
}
}
diff --git a/indra/llimage/llimagejpeg.cpp b/indra/llimage/llimagejpeg.cpp
index c75e449db5..b1ab279de7 100644
--- a/indra/llimage/llimagejpeg.cpp
+++ b/indra/llimage/llimagejpeg.cpp
@@ -335,7 +335,12 @@ boolean LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo )
// Double the buffer size;
S32 new_buffer_size = self->mOutputBufferSize * 2;
U8* new_buffer = new U8[ new_buffer_size ];
- memcpy( new_buffer, self->mOutputBuffer, self->mOutputBufferSize );
+ if (!new_buffer)
+ {
+ llerrs << "Out of memory in LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo )" << llendl;
+ return FALSE;
+ }
+ memcpy( new_buffer, self->mOutputBuffer, self->mOutputBufferSize ); /* Flawfinder: ignore */
delete[] self->mOutputBuffer;
self->mOutputBuffer = new_buffer;
@@ -359,7 +364,7 @@ void LLImageJPEG::encodeTermDestination( j_compress_ptr cinfo )
S32 file_bytes = (S32)(self->mOutputBufferSize - cinfo->dest->free_in_buffer);
self->allocateData(file_bytes);
- memcpy( self->getData(), self->mOutputBuffer, file_bytes );
+ memcpy( self->getData(), self->mOutputBuffer, file_bytes ); /* Flawfinder: ignore */
}
// static
@@ -416,7 +421,7 @@ void LLImageJPEG::errorEmitMessage( j_common_ptr cinfo, int msg_level )
void LLImageJPEG::errorOutputMessage( j_common_ptr cinfo )
{
// Create the message
- char buffer[JMSG_LENGTH_MAX];
+ char buffer[JMSG_LENGTH_MAX]; /* Flawfinder: ignore */
(*cinfo->err->format_message) (cinfo, buffer);
((LLImageJPEG*) cinfo->client_data)->setLastError( buffer );
diff --git a/indra/llimage/llimagetga.cpp b/indra/llimage/llimagetga.cpp
index 1007f8e2bb..f19d85d754 100644
--- a/indra/llimage/llimagetga.cpp
+++ b/indra/llimage/llimagetga.cpp
@@ -183,7 +183,7 @@ BOOL LLImageTGA::updateData()
// discard the ID field, if any
if (mIDLength)
{
- memcpy(junk, getData()+mDataOffset, mIDLength);
+ memcpy(junk, getData()+mDataOffset, mIDLength); /* Flawfinder: ignore */
mDataOffset += mIDLength;
}
@@ -220,7 +220,12 @@ BOOL LLImageTGA::updateData()
if ( (1 == mImageType) || (9 == mImageType) )
{
mColorMap = new U8[ color_map_bytes ];
- memcpy( mColorMap, getData() + mDataOffset, color_map_bytes );
+ if (!mColorMap)
+ {
+ llerrs << "Out of Memory in BOOL LLImageTGA::updateData()" << llendl;
+ return FALSE;
+ }
+ memcpy( mColorMap, getData() + mDataOffset, color_map_bytes ); /* Flawfinder: ignore */
}
mDataOffset += color_map_bytes;
@@ -432,7 +437,7 @@ BOOL LLImageTGA::decodeTruecolorNonRle( LLImageRaw* raw_image, BOOL &alpha_opaqu
}
else if (getComponents() == 1)
{
- memcpy(dst, src, pixels);
+ memcpy(dst, src, pixels); /* Flawfinder: ignore */
}
return TRUE;
@@ -673,7 +678,7 @@ BOOL LLImageTGA::encode(const LLImageRaw* raw_image, F32 encode_time)
switch( getComponents() )
{
case 1:
- memcpy( dst, src, bytes_per_pixel * pixels );
+ memcpy( dst, src, bytes_per_pixel * pixels ); /* Flawfinder: ignore */
break;
case 2:
@@ -1053,7 +1058,7 @@ bool LLImageTGA::loadFile( const LLString& path )
return false;
}
- FILE *file = LLFile::fopen(path.c_str(), "rb");
+ FILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */
if( !file )
{
llwarns << "Couldn't open file " << path << llendl;