summaryrefslogtreecommitdiff
path: root/indra/llimage/llimagej2c.cpp
diff options
context:
space:
mode:
authorcallum_linden <none@none>2018-04-12 15:22:25 -0700
committercallum_linden <none@none>2018-04-12 15:22:25 -0700
commit6c953d0bde107059db75d01cd30326a31cd0de54 (patch)
treec41563bccdcccc3bb263cca68c12f90ce0dbde88 /indra/llimage/llimagej2c.cpp
parentbdd7bdf390775860fb26a6c7d0923f45bb20256c (diff)
parent41f4e854732a7c75a813b2e99285cc41bde13e5e (diff)
Automated merge with tip of viewer-release after Viewer Media Update release
Diffstat (limited to 'indra/llimage/llimagej2c.cpp')
-rw-r--r--indra/llimage/llimagej2c.cpp25
1 files changed, 17 insertions, 8 deletions
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);
+ }
}
}