From 8e8b87b257afeba8699c2d5790833a22dc8229de Mon Sep 17 00:00:00 2001 From: Ted Clancy Date: Tue, 12 May 2015 22:49:50 -0400 Subject: [PATCH] Bug 1161932 - Fix coverity warning in nsBidi.cpp. r=smontagu --- layout/base/nsBidi.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/layout/base/nsBidi.cpp b/layout/base/nsBidi.cpp index 904dd11ff150..e19ea75fc350 100644 --- a/layout/base/nsBidi.cpp +++ b/layout/base/nsBidi.cpp @@ -669,7 +669,7 @@ void nsBidi::ResolveExplicitLevels(nsBidiDirection *aDirection) uint16_t stack[NSBIDI_MAX_EXPLICIT_LEVEL + 2]; /* we never push anything >=NSBIDI_MAX_EXPLICIT_LEVEL but we need one more entry as base */ - uint32_t stackLast = 0; + int32_t stackLast = 0; int32_t overflowIsolateCount = 0; int32_t overflowEmbeddingCount = 0; int32_t validIsolateCount = 0; @@ -773,8 +773,14 @@ void nsBidi::ResolveExplicitLevels(nsBidiDirection *aDirection) /* pop embedding entries */ /* until the last isolate entry */ stackLast--; + + // Since validIsolateCount is true, there must be an isolate entry + // on the stack, so the stack is guaranteed to not be empty. + // Still, to eliminate a warning from coverity, we use an assertion. + MOZ_ASSERT(stackLast > 0); } stackLast--; /* pop also the last isolate entry */ + MOZ_ASSERT(stackLast >= 0); // For coverity validIsolateCount--; } else { dirProps[i] |= IGNORE_CC;