diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-08-05 20:52:18 +0300 |
---|---|---|
committer | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-08-05 20:52:18 +0300 |
commit | 55983b9abdbbb5eedf8fb4e3e4a566dc5b1425f6 (patch) | |
tree | a6cfcc26247262304e87b77230c45ad21dd06f84 /indra | |
parent | 301c5ae4e216ec240a72fdb98940a98bf9019591 (diff) |
SL-10908 One more safeguard
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llimage/llimage.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 680fbf548f..aed8943439 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -2178,19 +2178,27 @@ bool LLImageFormatted::load(const std::string &filename, int load_size) } bool res; U8 *data = allocateData(load_size); - apr_size_t bytes_read = load_size; - apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read - if (s != APR_SUCCESS || (S32) bytes_read != load_size) + if (data) { - deleteData(); - setLastError("Unable to read file",filename); - res = false; + apr_size_t bytes_read = load_size; + apr_status_t s = apr_file_read(apr_file, data, &bytes_read); // modifies bytes_read + if (s != APR_SUCCESS || (S32) bytes_read != load_size) + { + deleteData(); + setLastError("Unable to read file",filename); + res = false; + } + else + { + res = updateData(); + } } else { - res = updateData(); + setLastError("Allocation failure", filename); + res = false; } - + return res; } |