diff --git a/layout/base/nsBidi.cpp b/layout/base/nsBidi.cpp
--- a/layout/base/nsBidi.cpp
+++ b/layout/base/nsBidi.cpp
@@ -648,17 +648,18 @@ nsBidi::BracketData::ProcessLRI_RLI(nsBi
     GET_LR_FROM_LEVEL(aLevel);
   currIsoRun.contextPos = 0;
 }
 
 /* PDI */
 void
 nsBidi::BracketData::ProcessPDI()
 {
-  mIsoRuns[mIsoRunLast].lastBase = O_N;
+  MOZ_ASSERT(mIsoRunLast > 0);
+  mIsoRuns[--mIsoRunLast].lastBase = O_N;
 }
 
 /* newly found opening bracket: create an openings entry */
 bool                            /* return true if success */
 nsBidi::BracketData::AddOpening(char16_t aMatch, int32_t aPosition)
 {
   IsoRun& lastIsoRun = mIsoRuns[mIsoRunLast];
   if (lastIsoRun.limit >= mOpeningsCount) {  /* no available new entry */
