summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp7
-rw-r--r--indra/llimage/llimagedimensionsinfo.cpp2
-rw-r--r--indra/llimage/llimagej2c.cpp25
3 files changed, 24 insertions, 10 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index cd7125197c..4a76d15096 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -748,7 +748,11 @@ U8* LLImageBase::allocateData(S32 size)
{
size = 0;
mWidth = mHeight = 0;
- mData = NULL;
+ if (mData)
+ {
+ deleteData(); // virtual
+ mData = NULL;
+ }
}
mDataSize = size;
claimMem(mDataSize);
@@ -775,6 +779,7 @@ U8* LLImageBase::reallocateData(S32 size)
disclaimMem(mDataSize);
mDataSize = size;
claimMem(mDataSize);
+ mBadBufferAllocation = false;
return mData;
}
diff --git a/indra/llimage/llimagedimensionsinfo.cpp b/indra/llimage/llimagedimensionsinfo.cpp
index a5e546e977..97b543f3b6 100644
--- a/indra/llimage/llimagedimensionsinfo.cpp
+++ b/indra/llimage/llimagedimensionsinfo.cpp
@@ -163,7 +163,7 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg()
{
sJpegErrorEncountered = false;
clean();
- FILE *fp = fopen (mSrcFilename.c_str(), "rb");
+ FILE *fp = LLFile::fopen(mSrcFilename, "rb");
if (fp == NULL)
{
setLastError("Unable to open file for reading", mSrcFilename);
diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp
index 68694496bc..c40df009d8 100644
--- a/indra/llimage/llimagej2c.cpp
+++ b/indra/llimage/llimagej2c.cpp
@@ -369,19 +369,28 @@ bool LLImageJ2C::loadAndValidate(const std::string &filename)
else
{
U8 *data = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), file_size);
- apr_size_t bytes_read = file_size;
- apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read
- infile.close() ;
-
- if (s != APR_SUCCESS || (S32)bytes_read != file_size)
+ if (!data)
{
- FREE_MEM(LLImageBase::getPrivatePool(), data);
- setLastError("Unable to read entire file");
+ infile.close();
+ setLastError("Out of memory", filename);
res = false;
}
else
{
- res = validate(data, file_size);
+ apr_size_t bytes_read = file_size;
+ apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read
+ infile.close();
+
+ if (s != APR_SUCCESS || (S32)bytes_read != file_size)
+ {
+ FREE_MEM(LLImageBase::getPrivatePool(), data);
+ setLastError("Unable to read entire file");
+ res = false;
+ }
+ else
+ {
+ res = validate(data, file_size);
+ }
}
}