blob: a66c2da08d76f7a8d1635e529b47d6866967bf05 [file] [log] [blame]
diff --git a/source/common/ubidi.c b/source/common/ubidi.c
index 8c0d64b..c43c41c 100644
--- a/source/common/ubidi.c
+++ b/source/common/ubidi.c
@@ -1,7 +1,7 @@
/*
******************************************************************************
*
-* Copyright (C) 1999-2014, International Business Machines
+* Copyright (C) 1999-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@@ -2138,7 +2138,7 @@ resolveImplicitLevels(UBiDi *pBiDi,
/* The isolates[] entries contain enough information to
resume the bidi algorithm in the same state as it was
when it was interrupted by an isolate sequence. */
- if(dirProps[start]==PDI) {
+ if(dirProps[start]==PDI && pBiDi->isolateCount >= 0) {
levState.startON=pBiDi->isolates[pBiDi->isolateCount].startON;
start1=pBiDi->isolates[pBiDi->isolateCount].start1;
stateImp=pBiDi->isolates[pBiDi->isolateCount].stateImp;
@@ -2340,7 +2340,7 @@ setParaSuccess(UBiDi *pBiDi) {
static void
setParaRunsOnly(UBiDi *pBiDi, const UChar *text, int32_t length,
UBiDiLevel paraLevel, UErrorCode *pErrorCode) {
- void *runsOnlyMemory;
+ void *runsOnlyMemory = NULL;
int32_t *visualMap;
UChar *visualText;
int32_t saveLength, saveTrailingWSStart;
@@ -2514,12 +2514,13 @@ setParaRunsOnly(UBiDi *pBiDi, const UChar *text, int32_t length,
}
uprv_memcpy(pBiDi->levels, saveLevels, saveLength*sizeof(UBiDiLevel));
pBiDi->trailingWSStart=saveTrailingWSStart;
- /* free memory for mapping table and visual text */
- uprv_free(runsOnlyMemory);
if(pBiDi->runCount>1) {
pBiDi->direction=UBIDI_MIXED;
}
cleanup3:
+ /* free memory for mapping table and visual text */
+ uprv_free(runsOnlyMemory);
+
pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY;
}
diff --git a/source/common/ubidiimp.h b/source/common/ubidiimp.h
index 20ab9b9..14d7b99 100644
--- a/source/common/ubidiimp.h
+++ b/source/common/ubidiimp.h
@@ -1,7 +1,7 @@
/*
******************************************************************************
*
-* Copyright (C) 1999-2014, International Business Machines
+* Copyright (C) 1999-2015, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@@ -184,8 +184,8 @@ typedef struct BracketData {
typedef struct Isolate {
int32_t startON;
int32_t start1;
+ int32_t state;
int16_t stateImp;
- int16_t state;
} Isolate;
typedef struct Run {