summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2017-06-09 08:46:34 +0300
committerAndreyL ProductEngine <alihatskiy@productengine.com>2017-06-09 08:46:34 +0300
commit2b6ab45210113950ea575ef62280c15fad30ff96 (patch)
tree9ccda3e86d8ee1492df7657a92498ca11152ab7b
parentc47bf2656fe83b3ed9ab1008d5ea537c74d620fd (diff)
parent7cc9455fe1b8a6194f52062c90761fffa6ae6fdc (diff)
Merged in lindenlab/viewer-lynx
-rw-r--r--indra/llcommon/llsdserialize.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index 0568a639a0..3a219eb998 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -2091,13 +2091,18 @@ std::string zip_llsd(LLSD& data)
}
have = CHUNK-strm.avail_out;
- output = (U8*) realloc(output, cur_size+have);
- if (output == NULL)
+ 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;
}
@@ -2180,14 +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);
- if (result == NULL)
+ 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;
@@ -2279,15 +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);
- if (result == NULL)
+ 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;