From 3be4e074421bd2d293d30edd79cdfb27f6501847 Mon Sep 17 00:00:00 2001 From: Nicky Date: Wed, 2 Jan 2013 18:48:29 +0100 Subject: [PATCH] Use nd::exceptions::xran to handle out of bounds errors in datapacker instead of a plain std::string. --- indra/llmessage/lldatapacker.h | 4 +++- indra/llmessage/llmessagetemplate.h | 6 ++++-- indra/llmessage/lltemplatemessagereader.cpp | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/indra/llmessage/lldatapacker.h b/indra/llmessage/lldatapacker.h index 940c797b77..525e400ef4 100644 --- a/indra/llmessage/lldatapacker.h +++ b/indra/llmessage/lldatapacker.h @@ -27,6 +27,8 @@ #ifndef LL_LLDATAPACKER_H #define LL_LLDATAPACKER_H +#include "ndexceptions.h" // For ndxran + class LLColor4; class LLColor4U; class LLVector2; @@ -208,7 +210,7 @@ inline BOOL LLDataPackerBinaryBuffer::verifyLength(const S32 data_size, const ch std::stringstream strm; strm << "Buffer overflow in BinaryBuffer length verify, field name " << name << "!" << std::endl; strm << "Current pos: " << (int)(mCurBufferp - mBufferp) << " Buffer size: " << mBufferSize << " Data size: " << data_size << std::endl; - throw std::string( strm.str() ); + throw nd::exceptions::xran( strm.str() ); // } diff --git a/indra/llmessage/llmessagetemplate.h b/indra/llmessage/llmessagetemplate.h index 370810e688..675163b4bc 100644 --- a/indra/llmessage/llmessagetemplate.h +++ b/indra/llmessage/llmessagetemplate.h @@ -32,6 +32,8 @@ #include "llstat.h" #include "llstl.h" +#include "ndexceptions.h" // For ndxran + class LLMsgVarData { public: @@ -374,9 +376,9 @@ public: { mHandlerFunc(msgsystem, mUserData); } - catch( std::string &why ) + catch( nd::exceptions::xran &ex ) { - llwarns << why << llendl; + llwarns << ex.what() << llendl; } // diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp index f10098039b..fbc0018c0b 100644 --- a/indra/llmessage/lltemplatemessagereader.cpp +++ b/indra/llmessage/lltemplatemessagereader.cpp @@ -38,6 +38,8 @@ #include "v3math.h" #include "v4math.h" +#include "ndexceptions.h" // For ndxran + LLTemplateMessageReader::LLTemplateMessageReader(message_template_number_map_t& number_template_map) : mReceiveSize(0), @@ -542,7 +544,7 @@ void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host, const S3 << getMessageName() << std::endl; } gMessageSystem->callExceptionFunc(MX_RAN_OFF_END_OF_PACKET); - throw std::string( strm.str() ); + throw nd::exceptions::xran( strm.str() ); } static LLFastTimer::DeclareTimer FTM_PROCESS_MESSAGES("Process Messages");