summaryrefslogtreecommitdiff
path: root/indra/llcorehttp/bufferarray.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2018-01-17 12:43:28 -0500
committerOz Linden <oz@lindenlab.com>2018-01-17 12:43:28 -0500
commitd7c8678c3aa46aed09dce6c1edfc196e72d4b428 (patch)
tree538a1ef15c2e28676f6a7618bc1e0b5749e2bcea /indra/llcorehttp/bufferarray.cpp
parent9e4b977b2fbb565cef88f3d72e07dbdf8cb2cd69 (diff)
parent7acbd8ed8d73c507675d45360df07d232c431a8b (diff)
merge 5.1.0-release
Diffstat (limited to 'indra/llcorehttp/bufferarray.cpp')
-rw-r--r--indra/llcorehttp/bufferarray.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/indra/llcorehttp/bufferarray.cpp b/indra/llcorehttp/bufferarray.cpp
index 8eaaeed710..be534b3ce4 100644
--- a/indra/llcorehttp/bufferarray.cpp
+++ b/indra/llcorehttp/bufferarray.cpp
@@ -25,6 +25,8 @@
*/
#include "bufferarray.h"
+#include "llexception.h"
+#include "llmemory.h"
// BufferArray is a list of chunks, each a BufferArray::Block, of contiguous
@@ -140,8 +142,22 @@ size_t BufferArray::append(const void * src, size_t len)
{
mBlocks.reserve(mBlocks.size() + 5);
}
- Block * block = Block::alloc(BLOCK_ALLOC_SIZE);
- memcpy(block->mData, c_src, copy_len);
+ Block * block;
+ try
+ {
+ block = Block::alloc(BLOCK_ALLOC_SIZE);
+ }
+ catch (std::bad_alloc)
+ {
+ LLMemory::logMemoryInfo(TRUE);
+
+ //output possible call stacks to log file.
+ LLError::LLCallStacks::print();
+
+ LL_WARNS() << "Bad memory allocation in thrown by Block::alloc in read!" << LL_ENDL;
+ break;
+ }
+ memcpy(block->mData, c_src, copy_len);
block->mUsed = copy_len;
llassert_always(block->mUsed <= block->mAlloced);
mBlocks.push_back(block);
@@ -149,7 +165,7 @@ size_t BufferArray::append(const void * src, size_t len)
c_src += copy_len;
len -= copy_len;
}
- return ret;
+ return ret - len;
}