MAINT-8022 Handling memory errors in unzip_llsdNavMesh

Mon, 19 Feb 2018 21:30:48 +0200

author
andreykproductengine <andreykproductengine@lindenlab.com>
date
Mon, 19 Feb 2018 21:30:48 +0200
changeset 55291
f8fff11129d1
parent 55290
74516ccad384
child 55292
43f9351c7f6f

MAINT-8022 Handling memory errors in unzip_llsdNavMesh

indra/llcommon/llsdserialize.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llcommon/llsdserialize.cpp	Fri Feb 16 20:52:10 2018 +0000
     1.2 +++ b/indra/llcommon/llsdserialize.cpp	Mon Feb 19 21:30:48 2018 +0200
     1.3 @@ -2262,13 +2262,24 @@
     1.4  //and trailers are different for the formats.
     1.5  U8* unzip_llsdNavMesh( bool& valid, unsigned int& outsize, std::istream& is, S32 size )
     1.6  {
     1.7 +	if (size == 0)
     1.8 +	{
     1.9 +		LL_WARNS() << "No data to unzip." << LL_ENDL;
    1.10 +		return NULL;
    1.11 +	}
    1.12 +
    1.13  	U8* result = NULL;
    1.14  	U32 cur_size = 0;
    1.15  	z_stream strm;
    1.16  		
    1.17  	const U32 CHUNK = 0x4000;
    1.18  
    1.19 -	U8 *in = new U8[size];
    1.20 +	U8 *in = new(std::nothrow) U8[size];
    1.21 +	if (in == NULL)
    1.22 +	{
    1.23 +		LL_WARNS() << "Memory allocation failure." << LL_ENDL;
    1.24 +		return NULL;
    1.25 +	}
    1.26  	is.read((char*) in, size); 
    1.27  
    1.28  	U8 out[CHUNK];

mercurial