Skip to content

Commit

Permalink
llimage merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyotl committed Apr 6, 2016
1 parent 0841479 commit 6ced172
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
14 changes: 14 additions & 0 deletions indra/llimage/llimagebmp.cpp
Expand Up @@ -449,6 +449,10 @@ BOOL LLImageBMP::decodeColorMask32( U8* dst, U8* src )
mBitfieldMask[2] = 0x000000FF;
}

if (getWidth() * getHeight() * 4 > getDataSize() - mBitmapOffset)
{ //here we have situation when data size in src less than actually needed
return FALSE;
}

S32 src_row_span = getWidth() * 4;
S32 alignment_bytes = (3 * src_row_span) % 4; // round up to nearest multiple of 4
Expand Down Expand Up @@ -482,6 +486,11 @@ BOOL LLImageBMP::decodeColorTable8( U8* dst, U8* src )
S32 src_row_span = getWidth() * 1;
S32 alignment_bytes = (3 * src_row_span) % 4; // round up to nearest multiple of 4

if ((getWidth() * getHeight()) + getHeight() * alignment_bytes > getDataSize() - mBitmapOffset)
{ //here we have situation when data size in src less than actually needed
return FALSE;
}

for( S32 row = 0; row < getHeight(); row++ )
{
for( S32 col = 0; col < getWidth(); col++ )
Expand All @@ -507,6 +516,11 @@ BOOL LLImageBMP::decodeTruecolor24( U8* dst, U8* src )
S32 src_row_span = getWidth() * 3;
S32 alignment_bytes = (3 * src_row_span) % 4; // round up to nearest multiple of 4

if ((getWidth() * getHeight() * 3) + getHeight() * alignment_bytes > getDataSize() - mBitmapOffset)
{ //here we have situation when data size in src less than actually needed
return FALSE;
}

for( S32 row = 0; row < getHeight(); row++ )
{
for( S32 col = 0; col < getWidth(); col++ )
Expand Down
6 changes: 6 additions & 0 deletions indra/llimage/llimagetga.cpp
Expand Up @@ -437,7 +437,13 @@ BOOL LLImageTGA::decodeTruecolorNonRle( LLImageRaw* raw_image, BOOL &alpha_opaqu
// Origin is the bottom left
U8* dst = raw_image->getData();
U8* src = getData() + mDataOffset;

S32 pixels = getWidth() * getHeight();

if (pixels * (mIs15Bit ? 2 : getComponents()) > getDataSize() - (S32)mDataOffset)
{ //here we have situation when data size in src less than actually needed
return FALSE;
}

if (getComponents() == 4)
{
Expand Down
8 changes: 5 additions & 3 deletions indra/llimage/llimageworker.cpp
Expand Up @@ -35,18 +35,20 @@
LLImageDecodeThread::LLImageDecodeThread(bool threaded)
: LLQueuedThread("imagedecode", threaded)
{
mCreationMutex = new LLMutex();
}

//virtual
LLImageDecodeThread::~LLImageDecodeThread()
{
delete mCreationMutex ;
}

// MAIN THREAD
// virtual
S32 LLImageDecodeThread::update(F32 max_time_ms)
{
LLMutexLock lock(&mCreationMutex);
LLMutexLock lock(mCreationMutex);
for (creation_list_t::iterator iter = mCreationList.begin();
iter != mCreationList.end(); ++iter)
{
Expand All @@ -69,7 +71,7 @@ S32 LLImageDecodeThread::update(F32 max_time_ms)
LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLImageFormatted* image,
U32 priority, S32 discard, BOOL needs_aux, Responder* responder)
{
LLMutexLock lock(&mCreationMutex);
LLMutexLock lock(mCreationMutex);
handle_t handle = generateHandle();
mCreationList.push_back(creation_info(handle, image, priority, discard, needs_aux, responder));
return handle;
Expand All @@ -79,7 +81,7 @@ LLImageDecodeThread::handle_t LLImageDecodeThread::decodeImage(LLImageFormatted*
// Returns the size of the mutex guarded list as an indication of sanity
S32 LLImageDecodeThread::tut_size()
{
LLMutexLock lock(&mCreationMutex);
LLMutexLock lock(mCreationMutex);
S32 res = mCreationList.size();
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion indra/llimage/llimageworker.h
Expand Up @@ -98,7 +98,7 @@ class LLImageDecodeThread : public LLQueuedThread
};
typedef std::list<creation_info> creation_list_t;
creation_list_t mCreationList;
LLMutex mCreationMutex;
LLMutex* mCreationMutex;
};

#endif
11 changes: 1 addition & 10 deletions indra/llimage/llpngwrapper.h
Expand Up @@ -26,16 +26,7 @@
#ifndef LL_LLPNGWRAPPER_H
#define LL_LLPNGWRAPPER_H

#if LL_STANDALONE || (LL_LINUX && defined(__x86_64__))
#include <png.h>
#else
// Workaround for wrongly packaged prebuilt.
#if _MSC_VER >= 1800
#include <libpng16/png.h>
#else
#include "libpng15/png.h"
#endif
#endif
#include "png.h"
#include "llimage.h"

class LLPngWrapper
Expand Down

0 comments on commit 6ced172

Please sign in to comment.