summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp17
-rw-r--r--indra/llimage/llimage.h2
-rw-r--r--indra/llimage/llimagebmp.cpp5
3 files changed, 16 insertions, 8 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index d7ae9611fc..ef1467ce50 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -145,7 +145,6 @@ U8* LLImageBase::allocateData(S32 size)
mData = new U8[size];
if (!mData)
{
- //llerrs << "allocate image data: " << size << llendl;
llwarns << "allocate image data: " << size << llendl;
size = 0 ;
mWidth = mHeight = 0 ;
@@ -243,8 +242,10 @@ LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
: LLImageBase()
{
mMemType = LLMemType::MTYPE_IMAGERAW;
- allocateDataSize(width, height, components);
- memcpy(getData(), data, width*height*components);
+ if(allocateDataSize(width, height, components))
+ {
+ memcpy(getData(), data, width*height*components);
+ }
++sRawImageCount;
}
@@ -795,7 +796,7 @@ void LLImageRaw::copyScaled( LLImageRaw* src )
}
-void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
+BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
{
LLMemType mt1((LLMemType::EMemType)mMemType);
llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) );
@@ -805,7 +806,7 @@ void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
if( (old_width == new_width) && (old_height == new_height) )
{
- return; // Nothing to do.
+ return TRUE; // Nothing to do.
}
// Reallocate the data buffer.
@@ -840,8 +841,10 @@ void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
U8* temp_buffer = new U8[ temp_data_size ];
if (!temp_buffer)
{
- llerrs << "Out of memory in LLImageRaw::scale: old (w, h, c) = (" << old_width << ", " << old_height << ", " << (S32)getComponents() <<
+ llwarns << "Out of memory in LLImageRaw::scale: old (w, h, c) = (" << old_width << ", " << old_height << ", " << (S32)getComponents() <<
") ; new (w, h, c) = (" << new_width << ", " << new_height << ", " << (S32)getComponents() << ")" << llendl;
+
+ return FALSE ;
}
memcpy(temp_buffer, getData(), temp_data_size); /* Flawfinder: ignore */
@@ -869,6 +872,8 @@ void LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
// Clean up
delete[] temp_buffer;
}
+
+ return TRUE ;
}
void LLImageRaw::copyLineScaled( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len, S32 in_pixel_step, S32 out_pixel_step )
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index c4fd661976..8db6a6c5bd 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -176,7 +176,7 @@ public:
void expandToPowerOfTwo(S32 max_dim = MAX_IMAGE_SIZE, BOOL scale_image = TRUE);
void contractToPowerOfTwo(S32 max_dim = MAX_IMAGE_SIZE, BOOL scale_image = TRUE);
void biasedScaleToPowerOfTwo(S32 max_dim = MAX_IMAGE_SIZE);
- void scale( S32 new_width, S32 new_height, BOOL scale_image = TRUE );
+ BOOL scale( S32 new_width, S32 new_height, BOOL scale_image = TRUE );
// Fill the buffer with a constant color
void fill( const LLColor4U& color );
diff --git a/indra/llimage/llimagebmp.cpp b/indra/llimage/llimagebmp.cpp
index b6b1d695d1..477119b82d 100644
--- a/indra/llimage/llimagebmp.cpp
+++ b/indra/llimage/llimagebmp.cpp
@@ -552,7 +552,10 @@ BOOL LLImageBMP::encode(const LLImageRaw* raw_image, F32 encode_time)
int file_bytes = line_bytes*getHeight() + header_bytes;
// Allocate the new buffer for the data.
- allocateData(file_bytes);
+ if(!allocateData(file_bytes)) //memory allocation failed
+ {
+ return FALSE ;
+ }
magic[0] = 'B'; magic[1] = 'M';
magic[2] = (U8) file_bytes;