Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Unified Diff: patches/bidi.patch

Issue 907333002: Apply an upstream patch for a resource leak in BiDi (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « README.chromium ('k') | source/common/ubidi.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: patches/bidi.patch
diff --git a/patches/bidi.patch b/patches/bidi.patch
index 5a43e4cee81e22fe15b36a24d7e9c37a271666a6..41764f07b125478976957bf6a9cfa6ac9b75aca0 100644
--- a/patches/bidi.patch
+++ b/patches/bidi.patch
@@ -1,95 +1,38 @@
-Index: source/test/cintltst/cbiditst.c
-===================================================================
---- source/test/cintltst/cbiditst.c (revision 36303)
-+++ source/test/cintltst/cbiditst.c (revision 36304)
-@@ -87,6 +87,8 @@
-
- static void doTailTest(void);
-
-+static void testBracketOverflow(void);
-+
- /* new BIDI API */
- static void testReorderingMode(void);
- static void testReorderRunsOnly(void);
-@@ -133,6 +135,7 @@
- addTest(root, testClassOverride, "complex/bidi/TestClassOverride");
- addTest(root, testGetBaseDirection, "complex/bidi/testGetBaseDirection");
- addTest(root, testContext, "complex/bidi/testContext");
-+ addTest(root, testBracketOverflow, "complex/bidi/TestBracketOverflow");
-
- addTest(root, doArabicShapingTest, "complex/arabic-shaping/ArabicShapingTest");
- addTest(root, doLamAlefSpecialVLTRArabicShapingTest, "complex/arabic-shaping/lamalef");
-@@ -4896,3 +4899,25 @@
-
- log_verbose("\nExiting TestContext \n\n");
- }
-+
-+/* Ticket#11054 ubidi_setPara crash with heavily nested brackets */
-+static void
-+testBracketOverflow(void) {
-+ static const char* TEXT = "(((((((((((((((((((((((((((((((((((((((((a)(A)))))))))))))))))))))))))))))))))))))))))";
-+ UErrorCode status = U_ZERO_ERROR;
-+ UBiDi* bidi;
-+ UChar src[100];
-+ UChar dest[100];
-+ int32_t len;
-+
-+ bidi = ubidi_open();
-+ len = uprv_strlen(TEXT);
-+ pseudoToU16(len, TEXT, src);
-+ ubidi_setPara(bidi, src, len, UBIDI_DEFAULT_LTR , NULL, &status);
-+ if (U_FAILURE(status)) {
-+ log_err("setPara failed with heavily nested brackets - %s", u_errorName(status));
-+ }
-+
-+ ubidi_close(bidi);
-+}
-+
-Index: source/common/ubidiimp.h
-===================================================================
---- source/common/ubidiimp.h (revision 36303)
-+++ source/common/ubidiimp.h (revision 36304)
-@@ -173,7 +173,7 @@
- /* array of opening entries which should be enough in most cases; no malloc() */
- Opening simpleOpenings[SIMPLE_OPENINGS_SIZE];
- Opening *openings; /* pointer to current array of entries */
-- int32_t openingsSize; /* number of allocated entries */
-+ int32_t openingsCount; /* number of allocated entries */
- int32_t isoRunLast; /* index of last used entry */
- /* array of nested isolated sequence entries; can never excess UBIDI_MAX_EXPLICIT_LEVEL
- + 1 for index 0, + 1 for before the first isolated sequence */
-Index: source/common/ubidi.c
-===================================================================
---- source/common/ubidi.c (revision 36303)
-+++ source/common/ubidi.c (revision 36304)
-@@ -679,10 +679,10 @@
- bd->isoRuns[0].contextPos=0;
- if(pBiDi->openingsMemory) {
- bd->openings=pBiDi->openingsMemory;
-- bd->openingsSize=pBiDi->openingsSize;
-+ bd->openingsCount=pBiDi->openingsSize / sizeof(Opening);
- } else {
- bd->openings=bd->simpleOpenings;
-- bd->openingsSize=SIMPLE_OPENINGS_SIZE;
-+ bd->openingsCount=SIMPLE_OPENINGS_SIZE;
+diff --git a/source/common/ubidi.c b/source/common/ubidi.c
+index 8c0d64b..e773de7 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.
+ *
+ ******************************************************************************
+@@ -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,
}
- bd->isNumbersSpecial=bd->pBiDi->reorderingMode==UBIDI_REORDER_NUMBERS_SPECIAL ||
- bd->pBiDi->reorderingMode==UBIDI_REORDER_INVERSE_FOR_NUMBERS_SPECIAL;
-@@ -743,7 +743,7 @@
- bracketAddOpening(BracketData *bd, UChar match, int32_t position) {
- IsoRun *pLastIsoRun=&bd->isoRuns[bd->isoRunLast];
- Opening *pOpening;
-- if(pLastIsoRun->limit>=bd->openingsSize) { /* no available new entry */
-+ if(pLastIsoRun->limit>=bd->openingsCount) { /* no available new entry */
- UBiDi *pBiDi=bd->pBiDi;
- if(!getInitialOpeningsMemory(pBiDi, pLastIsoRun->limit * 2))
- return FALSE;
-@@ -751,7 +751,7 @@
- uprv_memcpy(pBiDi->openingsMemory, bd->simpleOpenings,
- SIMPLE_OPENINGS_SIZE * sizeof(Opening));
- bd->openings=pBiDi->openingsMemory; /* may have changed */
-- bd->openingsSize=pBiDi->openingsSize;
-+ bd->openingsCount=pBiDi->openingsSize / sizeof(Opening);
+ 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;
}
- pOpening=&bd->openings[pLastIsoRun->limit];
- pOpening->position=position;
+ cleanup3:
++ /* free memory for mapping table and visual text */
++ uprv_free(runsOnlyMemory);
++
+ pBiDi->reorderingMode=UBIDI_REORDER_RUNS_ONLY;
+ }
+
« no previous file with comments | « README.chromium ('k') | source/common/ubidi.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698