diff options
author | Oz Linden <oz@lindenlab.com> | 2017-08-16 15:43:58 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2017-08-16 15:43:58 -0400 |
commit | 01e0b78c595e346bef4e771f9580006dd895367c (patch) | |
tree | 90160c9edb07baa4fcfd022082608f96b1bfdc06 /indra/llcommon | |
parent | 2368c44a8e2b031e5a8ac199923a016915cfe96a (diff) | |
parent | cf865bb5962a85e2da3414468d6a99ecb5423f97 (diff) |
merge changes for DRTVWR-439
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llsdserialize.cpp | 42 | ||||
-rw-r--r-- | indra/llcommon/llstring.h | 4 |
2 files changed, 43 insertions, 3 deletions
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index 81ba8631c6..3a219eb998 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -2091,7 +2091,18 @@ std::string zip_llsd(LLSD& data) } have = CHUNK-strm.avail_out; - output = (U8*) realloc(output, cur_size+have); + U8* new_output = (U8*) realloc(output, cur_size+have); + if (new_output == NULL) + { + LL_WARNS() << "Failed to compress LLSD block: can't reallocate memory, current size: " << cur_size << " bytes; requested " << cur_size + have << " bytes." << LL_ENDL; + deflateEnd(&strm); + if (output) + { + free(output); + } + return std::string(); + } + output = new_output; memcpy(output+cur_size, out, have); cur_size += have; } @@ -2174,7 +2185,19 @@ bool unzip_llsd(LLSD& data, std::istream& is, S32 size) U32 have = CHUNK-strm.avail_out; - result = (U8*) realloc(result, cur_size + have); + U8* new_result = (U8*)realloc(result, cur_size + have); + if (new_result == NULL) + { + LL_WARNS() << "Failed to unzip LLSD block: can't reallocate memory, current size: " << cur_size << " bytes; requested " << cur_size + have << " bytes." << LL_ENDL; + inflateEnd(&strm); + if (result) + { + free(result); + } + delete[] in; + return false; + } + result = new_result; memcpy(result+cur_size, out, have); cur_size += have; @@ -2266,7 +2289,20 @@ U8* unzip_llsdNavMesh( bool& valid, unsigned int& outsize, std::istream& is, S32 U32 have = CHUNK-strm.avail_out; - result = (U8*) realloc(result, cur_size + have); + U8* new_result = (U8*) realloc(result, cur_size + have); + if (new_result == NULL) + { + LL_WARNS() << "Failed to unzip LLSD NavMesh block: can't reallocate memory, current size: " << cur_size << " bytes; requested " << cur_size + have << " bytes." << LL_ENDL; + inflateEnd(&strm); + if (result) + { + free(result); + } + delete[] in; + valid = false; + return NULL; + } + result = new_result; memcpy(result+cur_size, out, have); cur_size += have; diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index a6629bc178..a4a5b393cb 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -1325,6 +1325,10 @@ void LLStringUtilBase<T>::removeCRLF(string_type& string) template<class T> void LLStringUtilBase<T>::removeWindowsCR(string_type& string) { + if (string.empty()) + { + return; + } const T LF = 10; const T CR = 13; |