summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2011-11-17 13:55:11 -0500
committerNat Goodspeed <nat@lindenlab.com>2011-11-17 13:55:11 -0500
commitbd5b1ed713506d365793c7f9cb49d506ce392e7a (patch)
tree4b23ec0f7261ad3e0598ed139ea0d0238b822dfc /indra
parent570ac04e167c97553a03f283ee0683cc4648601c (diff)
LLSD-14: Make dumpStats()/calcStats() implementation more robust
per Monty code review
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llsd.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp
index b0801745d7..39d1f3e35f 100644
--- a/indra/llcommon/llsd.cpp
+++ b/indra/llcommon/llsd.cpp
@@ -732,10 +732,10 @@ const LLSD& LLSD::Impl::undef()
void LLSD::Impl::dumpStats() const
{
S32 type_counts[LLSD::TypeLLSDNumTypes + 1];
- memset(&type_counts, 0, LLSD::TypeLLSDNumTypes * sizeof(S32));
+ memset(&type_counts, 0, sizeof(type_counts));
S32 share_counts[LLSD::TypeLLSDNumTypes + 1];
- memset(&share_counts, 0, LLSD::TypeLLSDNumTypes * sizeof(S32));
+ memset(&share_counts, 0, sizeof(share_counts));
// Add info from all the values this object has
calcStats(type_counts, share_counts);
@@ -753,11 +753,15 @@ void LLSD::Impl::dumpStats() const
void LLSD::Impl::calcStats(S32 type_counts[], S32 share_counts[]) const
-{
- type_counts[(S32) type()]++;
- if (shared())
+{
+ S32 type = S32(type());
+ if (0 <= type && type < LLSD::TypeLLSDNumTypes)
{
- share_counts[(S32) type()]++;
+ type_counts[type]++;
+ if (shared())
+ {
+ share_counts[type]++;
+ }
}
}