Compare commits
No commits in common. 'c9' and 'c8' have entirely different histories.
@ -1 +1 @@
|
|||||||
SOURCES/icu4c-67_1-src.tgz
|
SOURCES/icu4c-60_3-src.tgz
|
||||||
|
@ -1 +1 @@
|
|||||||
6822a4a94324d1ba591b3e8ef084e4491af253c1 SOURCES/icu4c-67_1-src.tgz
|
83e6eb1931aac0aae6e313b306b3ca332c017bc3 SOURCES/icu4c-60_3-src.tgz
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
From 23d76d88630ecee02515e2c8f5c8769cc795ae23 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Shane Carr <shane@unicode.org>
|
||||||
|
Date: Fri, 23 Mar 2018 00:56:16 +0000
|
||||||
|
Subject: [PATCH] ICU-13634 Adding integer overflow logic to ICU4C number
|
||||||
|
pipeline in places where it is in ICU4J.
|
||||||
|
|
||||||
|
X-SVN-Rev: 41136
|
||||||
|
|
||||||
|
diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp
|
||||||
|
index 83f08ac070..452e2fd79c 100644
|
||||||
|
--- a/icu4c/source/common/putil.cpp
|
||||||
|
+++ b/icu4c/source/common/putil.cpp
|
||||||
|
@@ -533,6 +533,30 @@ uprv_fmin(double x, double y)
|
||||||
|
return (x > y ? y : x);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#include <iostream>
|
||||||
|
+
|
||||||
|
+U_CAPI UBool U_EXPORT2
|
||||||
|
+uprv_add32_overflow(int32_t a, int32_t b, int32_t* res) {
|
||||||
|
+ // NOTE: Some compilers (GCC, Clang) have primitives available, like __builtin_add_overflow.
|
||||||
|
+ // This function could be optimized by calling one of those primitives.
|
||||||
|
+ auto a64 = static_cast<int64_t>(a);
|
||||||
|
+ auto b64 = static_cast<int64_t>(b);
|
||||||
|
+ int64_t res64 = a64 + b64;
|
||||||
|
+ *res = static_cast<int32_t>(res64);
|
||||||
|
+ return res64 != *res;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+U_CAPI UBool U_EXPORT2
|
||||||
|
+uprv_mul32_overflow(int32_t a, int32_t b, int32_t* res) {
|
||||||
|
+ // NOTE: Some compilers (GCC, Clang) have primitives available, like __builtin_mul_overflow.
|
||||||
|
+ // This function could be optimized by calling one of those primitives.
|
||||||
|
+ auto a64 = static_cast<int64_t>(a);
|
||||||
|
+ auto b64 = static_cast<int64_t>(b);
|
||||||
|
+ int64_t res64 = a64 * b64;
|
||||||
|
+ *res = static_cast<int32_t>(res64);
|
||||||
|
+ return res64 != *res;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Truncates the given double.
|
||||||
|
* trunc(3.3) = 3.0, trunc (-3.3) = -3.0
|
||||||
|
diff --git a/icu4c/source/common/putilimp.h b/icu4c/source/common/putilimp.h
|
||||||
|
index eb9b5380f1..8b858df9e3 100644
|
||||||
|
--- a/icu4c/source/common/putilimp.h
|
||||||
|
+++ b/icu4c/source/common/putilimp.h
|
||||||
|
@@ -391,6 +391,32 @@ U_INTERNAL double U_EXPORT2 uprv_log(double d);
|
||||||
|
*/
|
||||||
|
U_INTERNAL double U_EXPORT2 uprv_round(double x);
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * Adds the signed integers a and b, storing the result in res.
|
||||||
|
+ * Checks for signed integer overflow.
|
||||||
|
+ * Similar to the GCC/Clang extension __builtin_add_overflow
|
||||||
|
+ *
|
||||||
|
+ * @param a The first operand.
|
||||||
|
+ * @param b The second operand.
|
||||||
|
+ * @param res a + b
|
||||||
|
+ * @return true if overflow occurred; false if no overflow occurred.
|
||||||
|
+ * @internal
|
||||||
|
+ */
|
||||||
|
+U_INTERNAL UBool U_EXPORT2 uprv_add32_overflow(int32_t a, int32_t b, int32_t* res);
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Multiplies the signed integers a and b, storing the result in res.
|
||||||
|
+ * Checks for signed integer overflow.
|
||||||
|
+ * Similar to the GCC/Clang extension __builtin_mul_overflow
|
||||||
|
+ *
|
||||||
|
+ * @param a The first multiplicand.
|
||||||
|
+ * @param b The second multiplicand.
|
||||||
|
+ * @param res a * b
|
||||||
|
+ * @return true if overflow occurred; false if no overflow occurred.
|
||||||
|
+ * @internal
|
||||||
|
+ */
|
||||||
|
+U_INTERNAL UBool U_EXPORT2 uprv_mul32_overflow(int32_t a, int32_t b, int32_t* res);
|
||||||
|
+
|
||||||
|
#if 0
|
||||||
|
/**
|
||||||
|
* Returns the number of digits after the decimal point in a double number x.
|
||||||
|
diff --git a/icu4c/source/test/cintltst/putiltst.c b/icu4c/source/test/cintltst/putiltst.c
|
||||||
|
index b99d9fca9c..1c3e073041 100644
|
||||||
|
--- a/icu4c/source/test/cintltst/putiltst.c
|
||||||
|
+++ b/icu4c/source/test/cintltst/putiltst.c
|
||||||
|
@@ -128,6 +128,20 @@ static void TestPUtilAPI(void){
|
||||||
|
log_err("ERROR: uprv_isInfinite failed.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
+ log_verbose("Testing the APIs uprv_add32_overflow and uprv_mul32_overflow\n");
|
||||||
|
+ int32_t overflow_result;
|
||||||
|
+ doAssert(FALSE, uprv_add32_overflow(INT32_MAX - 2, 1, &overflow_result), "should not overflow");
|
||||||
|
+ doAssert(INT32_MAX - 1, overflow_result, "should equal INT32_MAX - 1");
|
||||||
|
+ doAssert(FALSE, uprv_add32_overflow(INT32_MAX - 2, 2, &overflow_result), "should not overflow");
|
||||||
|
+ doAssert(INT32_MAX, overflow_result, "should equal exactly INT32_MAX");
|
||||||
|
+ doAssert(TRUE, uprv_add32_overflow(INT32_MAX - 2, 3, &overflow_result), "should overflow");
|
||||||
|
+ doAssert(FALSE, uprv_mul32_overflow(INT32_MAX / 5, 4, &overflow_result), "should not overflow");
|
||||||
|
+ doAssert(INT32_MAX / 5 * 4, overflow_result, "should equal INT32_MAX / 5 * 4");
|
||||||
|
+ doAssert(TRUE, uprv_mul32_overflow(INT32_MAX / 5, 6, &overflow_result), "should overflow");
|
||||||
|
+ // Test on negative numbers:
|
||||||
|
+ doAssert(FALSE, uprv_add32_overflow(-3, -2, &overflow_result), "should not overflow");
|
||||||
|
+ doAssert(-5, overflow_result, "should equal -5");
|
||||||
|
+
|
||||||
|
#if 0
|
||||||
|
log_verbose("Testing the API uprv_digitsAfterDecimal()....\n");
|
||||||
|
doAssert(uprv_digitsAfterDecimal(value1), 3, "uprv_digitsAfterDecimal() failed.");
|
||||||
|
--
|
||||||
|
2.24.1
|
||||||
|
|
@ -0,0 +1,103 @@
|
|||||||
|
diff -ru icu/source/common/unistr.cpp icu.new/source/common/unistr.cpp
|
||||||
|
--- icu/source/common/unistr.cpp 2019-04-12 00:26:16.000000000 +0200
|
||||||
|
+++ icu.new/source/common/unistr.cpp 2020-03-03 15:39:37.069874709 +0100
|
||||||
|
@@ -1544,7 +1544,11 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t oldLength = length();
|
||||||
|
- int32_t newLength = oldLength + srcLength;
|
||||||
|
+ int32_t newLength;
|
||||||
|
+ if (uprv_add32_overflow(oldLength, srcLength, &newLength)) {
|
||||||
|
+ setToBogus();
|
||||||
|
+ return *this;
|
||||||
|
+ }
|
||||||
|
// optimize append() onto a large-enough, owned string
|
||||||
|
if((newLength <= getCapacity() && isBufferWritable()) ||
|
||||||
|
cloneArrayIfNeeded(newLength, getGrowCapacity(newLength))) {
|
||||||
|
diff -ru icu/source/test/intltest/ustrtest.cpp icu.new/source/test/intltest/ustrtest.cpp
|
||||||
|
--- icu/source/test/intltest/ustrtest.cpp 2019-04-12 00:26:16.000000000 +0200
|
||||||
|
+++ icu.new/source/test/intltest/ustrtest.cpp 2020-03-03 15:44:59.059239188 +0100
|
||||||
|
@@ -64,6 +64,7 @@
|
||||||
|
TESTCASE_AUTO(TestUInt16Pointers);
|
||||||
|
TESTCASE_AUTO(TestWCharPointers);
|
||||||
|
TESTCASE_AUTO(TestNullPointers);
|
||||||
|
+ TESTCASE_AUTO(TestLargeAppend);
|
||||||
|
TESTCASE_AUTO_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -2248,3 +2249,64 @@
|
||||||
|
UnicodeString(u"def").extract(nullptr, 0, errorCode);
|
||||||
|
assertEquals("buffer overflow extracting to nullptr", U_BUFFER_OVERFLOW_ERROR, errorCode);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+void UnicodeStringTest::TestLargeAppend() {
|
||||||
|
+ if(quick) return;
|
||||||
|
+
|
||||||
|
+ IcuTestErrorCode status(*this, "TestLargeAppend");
|
||||||
|
+ // Make a large UnicodeString
|
||||||
|
+ int32_t len = 0xAFFFFFF;
|
||||||
|
+ UnicodeString str;
|
||||||
|
+ char16_t *buf = str.getBuffer(len);
|
||||||
|
+ // A fast way to set buffer to valid Unicode.
|
||||||
|
+ // 4E4E is a valid unicode character
|
||||||
|
+ uprv_memset(buf, 0x4e, len * 2);
|
||||||
|
+ str.releaseBuffer(len);
|
||||||
|
+ UnicodeString dest;
|
||||||
|
+ // Append it 16 times
|
||||||
|
+ // 0xAFFFFFF times 16 is 0xA4FFFFF1,
|
||||||
|
+ // which is greater than INT32_MAX, which is 0x7FFFFFFF.
|
||||||
|
+ int64_t total = 0;
|
||||||
|
+ for (int32_t i = 0; i < 16; i++) {
|
||||||
|
+ dest.append(str);
|
||||||
|
+ total += len;
|
||||||
|
+ if (total <= INT32_MAX) {
|
||||||
|
+ assertFalse("dest is not bogus", dest.isBogus());
|
||||||
|
+ } else {
|
||||||
|
+ assertTrue("dest should be bogus", dest.isBogus());
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ dest.remove();
|
||||||
|
+ total = 0;
|
||||||
|
+ for (int32_t i = 0; i < 16; i++) {
|
||||||
|
+ dest.append(str);
|
||||||
|
+ total += len;
|
||||||
|
+ if (total + len <= INT32_MAX) {
|
||||||
|
+ assertFalse("dest is not bogus", dest.isBogus());
|
||||||
|
+ } else if (total <= INT32_MAX) {
|
||||||
|
+ // Check that a string of exactly the maximum size works
|
||||||
|
+ UnicodeString str2;
|
||||||
|
+ int32_t remain = INT32_MAX - total;
|
||||||
|
+ char16_t *buf2 = str2.getBuffer(remain);
|
||||||
|
+ if (buf2 == nullptr) {
|
||||||
|
+ // if somehow memory allocation fail, return the test
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ uprv_memset(buf2, 0x4e, remain * 2);
|
||||||
|
+ str2.releaseBuffer(remain);
|
||||||
|
+ dest.append(str2);
|
||||||
|
+ total += remain;
|
||||||
|
+ assertEquals("When a string of exactly the maximum size works", (int64_t)INT32_MAX, total);
|
||||||
|
+ assertEquals("When a string of exactly the maximum size works", INT32_MAX, dest.length());
|
||||||
|
+ assertFalse("dest is not bogus", dest.isBogus());
|
||||||
|
+
|
||||||
|
+ // Check that a string size+1 goes bogus
|
||||||
|
+ str2.truncate(1);
|
||||||
|
+ dest.append(str2);
|
||||||
|
+ total++;
|
||||||
|
+ assertTrue("dest should be bogus", dest.isBogus());
|
||||||
|
+ } else {
|
||||||
|
+ assertTrue("dest should be bogus", dest.isBogus());
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff -ru icu/source/test/intltest/ustrtest.h icu.new/source/test/intltest/ustrtest.h
|
||||||
|
--- icu/source/test/intltest/ustrtest.h 2019-04-12 00:26:16.000000000 +0200
|
||||||
|
+++ icu.new/source/test/intltest/ustrtest.h 2020-03-03 15:45:36.147935611 +0100
|
||||||
|
@@ -96,6 +96,7 @@
|
||||||
|
void TestUInt16Pointers();
|
||||||
|
void TestWCharPointers();
|
||||||
|
void TestNullPointers();
|
||||||
|
+ void TestLargeAppend();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,96 @@
|
|||||||
|
diff -ru orig.icu/source/test/cintltst/cnmdptst.c icu/source/test/cintltst/cnmdptst.c
|
||||||
|
--- orig.icu/source/test/cintltst/cnmdptst.c 2016-03-23 21:48:18.000000000 +0100
|
||||||
|
+++ icu/source/test/cintltst/cnmdptst.c 2016-04-15 18:34:06.148251985 +0200
|
||||||
|
@@ -186,6 +186,12 @@
|
||||||
|
/* Test exponential pattern*/
|
||||||
|
static void TestExponential(void)
|
||||||
|
{
|
||||||
|
+/* erAck: fails on armv7hl, https://bugzilla.redhat.com/show_bug.cgi?id=1239574 */
|
||||||
|
+#if 1
|
||||||
|
+ /* Actually only 3 tests fail, but given the nested structure depending on
|
||||||
|
+ * array sizes there's no simple "disable this and that". */
|
||||||
|
+ return;
|
||||||
|
+#endif
|
||||||
|
int32_t pat_length, val_length, lval_length;
|
||||||
|
int32_t ival, ilval, p, v, lneed;
|
||||||
|
UNumberFormat *fmt;
|
||||||
|
diff -ru orig.icu/source/test/intltest/dcfmtest.cpp icu/source/test/intltest/dcfmtest.cpp
|
||||||
|
--- orig.icu/source/test/intltest/dcfmtest.cpp 2016-03-23 21:48:38.000000000 +0100
|
||||||
|
+++ icu/source/test/intltest/dcfmtest.cpp 2016-04-15 18:34:06.148251985 +0200
|
||||||
|
@@ -279,6 +279,13 @@
|
||||||
|
//
|
||||||
|
formatLineMat.reset(testLine);
|
||||||
|
if (formatLineMat.lookingAt(status)) {
|
||||||
|
+/* erAck: fails on armv7hl, https://bugzilla.redhat.com/show_bug.cgi?id=1239574 */
|
||||||
|
+#if 1
|
||||||
|
+// [Formattable] file dcfmtest.txt, line 62: expected "12.35E5", got "1.235E6"
|
||||||
|
+// [StringPiece] file dcfmtest.txt, line 62: expected "12.35E5", got "1.235E6"
|
||||||
|
+ if (lineNum == 62)
|
||||||
|
+ continue;
|
||||||
|
+#endif
|
||||||
|
execFormatTest(lineNum,
|
||||||
|
formatLineMat.group(1, status), // Pattern
|
||||||
|
formatLineMat.group(2, status), // rounding mode
|
||||||
|
diff -ru orig.icu/source/test/intltest/numfmtspectest.cpp icu/source/test/intltest/numfmtspectest.cpp
|
||||||
|
--- orig.icu/source/test/intltest/numfmtspectest.cpp 2016-03-23 21:48:40.000000000 +0100
|
||||||
|
+++ icu/source/test/intltest/numfmtspectest.cpp 2016-04-15 18:34:06.148251985 +0200
|
||||||
|
@@ -137,11 +137,14 @@
|
||||||
|
|
||||||
|
void NumberFormatSpecificationTest::TestScientificNotation() {
|
||||||
|
assertPatternFr("1,23E4", 12345.0, "0.00E0", TRUE);
|
||||||
|
+/* erAck: fails on armv7hl, https://bugzilla.redhat.com/show_bug.cgi?id=1239574 */
|
||||||
|
+#if 0
|
||||||
|
assertPatternFr("123,00E2", 12300.0, "000.00E0", TRUE);
|
||||||
|
assertPatternFr("123,0E2", 12300.0, "000.0#E0", TRUE);
|
||||||
|
assertPatternFr("123,0E2", 12300.1, "000.0#E0", TRUE);
|
||||||
|
assertPatternFr("123,01E2", 12301.0, "000.0#E0", TRUE);
|
||||||
|
assertPatternFr("123,01E+02", 12301.0, "000.0#E+00", TRUE);
|
||||||
|
+#endif
|
||||||
|
assertPatternFr("12,3E3", 12345.0, "##0.00E0", TRUE);
|
||||||
|
assertPatternFr("12,300E3", 12300.1, "##0.0000E0", TRUE);
|
||||||
|
assertPatternFr("12,30E3", 12300.1, "##0.000#E0", TRUE);
|
||||||
|
@@ -221,6 +224,8 @@
|
||||||
|
assertEquals("", "USD (433.22)", result, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+/* erAck: fails on armv7hl, https://bugzilla.redhat.com/show_bug.cgi?id=1239574 */
|
||||||
|
+#if 0
|
||||||
|
const char *paddedSciPattern = "QU**00.#####E0";
|
||||||
|
assertPatternFr("QU***43,3E-1", 4.33, paddedSciPattern, TRUE);
|
||||||
|
{
|
||||||
|
@@ -242,6 +247,7 @@
|
||||||
|
}
|
||||||
|
// padding cannot work as intended with scientific notation.
|
||||||
|
assertPatternFr("QU**43,32E-1", 4.332, paddedSciPattern, TRUE);
|
||||||
|
+#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void NumberFormatSpecificationTest::assertPatternFr(
|
||||||
|
diff -ru orig.icu/source/test/intltest/numfmtst.cpp icu/source/test/intltest/numfmtst.cpp
|
||||||
|
--- orig.icu/source/test/intltest/numfmtst.cpp 2016-03-23 21:48:40.000000000 +0100
|
||||||
|
+++ icu/source/test/intltest/numfmtst.cpp 2016-04-15 18:34:06.150251997 +0200
|
||||||
|
@@ -730,6 +730,12 @@
|
||||||
|
void
|
||||||
|
NumberFormatTest::TestExponential(void)
|
||||||
|
{
|
||||||
|
+/* erAck: fails on armv7hl, https://bugzilla.redhat.com/show_bug.cgi?id=1239574 */
|
||||||
|
+#if 1
|
||||||
|
+ /* Actually only 3 tests fail, but given the nested structure depending on
|
||||||
|
+ * array sizes there's no simple "disable this and that". */
|
||||||
|
+ return;
|
||||||
|
+#endif
|
||||||
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
|
DecimalFormatSymbols sym(Locale::getUS(), status);
|
||||||
|
if (U_FAILURE(status)) { errcheckln(status, "FAIL: Bad status returned by DecimalFormatSymbols ct - %s", u_errorName(status)); return; }
|
||||||
|
@@ -1846,8 +1852,11 @@
|
||||||
|
(int32_t) 45678000, "5E7", status);
|
||||||
|
expect(new DecimalFormat("00E0", US, status),
|
||||||
|
(int32_t) 45678000, "46E6", status);
|
||||||
|
+/* erAck: fails on armv7hl, https://bugzilla.redhat.com/show_bug.cgi?id=1239574 */
|
||||||
|
+#if 0
|
||||||
|
expect(new DecimalFormat("000E0", US, status),
|
||||||
|
(int32_t) 45678000, "457E5", status);
|
||||||
|
+#endif
|
||||||
|
/*
|
||||||
|
expect(new DecimalFormat("###E0", US, status),
|
||||||
|
new Object[] { new Double(0.0000123), "12.3E-6",
|
@ -1,453 +0,0 @@
|
|||||||
diff -ru icu.orig/source/common/serv.cpp icu/source/common/serv.cpp
|
|
||||||
--- icu.orig/source/common/serv.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/serv.cpp 2021-08-18 13:04:50.838841089 +0200
|
|
||||||
@@ -532,12 +532,14 @@
|
|
||||||
}
|
|
||||||
UnicodeString* idToCache = new UnicodeString(currentDescriptor);
|
|
||||||
if (idToCache == NULL || idToCache->isBogus()) {
|
|
||||||
+ delete idToCache;
|
|
||||||
status = U_MEMORY_ALLOCATION_ERROR;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
cacheDescriptorList._obj->addElement(idToCache, status);
|
|
||||||
if (U_FAILURE(status)) {
|
|
||||||
+ // delete idToCache;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
} while (key.fallback());
|
|
||||||
diff -ru icu.orig/source/common/uloc_keytype.cpp icu/source/common/uloc_keytype.cpp
|
|
||||||
--- icu.orig/source/common/uloc_keytype.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/uloc_keytype.cpp 2021-08-18 14:03:41.707324553 +0200
|
|
||||||
@@ -331,6 +331,10 @@
|
|
||||||
LocExtKeyData* keyData = gLocExtKeyDataEntries->create();
|
|
||||||
if (keyData == NULL) {
|
|
||||||
sts = U_MEMORY_ALLOCATION_ERROR;
|
|
||||||
+ if (typeDataMap != NULL) {
|
|
||||||
+ uhash_close(typeDataMap);
|
|
||||||
+ typeDataMap = NULL;
|
|
||||||
+ }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
keyData->bcpId = bcpKeyId;
|
|
||||||
diff -ru icu.orig/source/common/umutablecptrie.cpp icu/source/common/umutablecptrie.cpp
|
|
||||||
--- icu.orig/source/common/umutablecptrie.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/umutablecptrie.cpp 2021-08-18 13:59:02.507170287 +0200
|
|
||||||
@@ -1543,7 +1543,7 @@
|
|
||||||
MixedBlocks mixedBlocks;
|
|
||||||
int32_t newDataLength = compactData(fastILimit, newData, newDataCapacity,
|
|
||||||
dataNullIndex, mixedBlocks, errorCode);
|
|
||||||
- if (U_FAILURE(errorCode)) { return 0; }
|
|
||||||
+ if (U_FAILURE(errorCode)) { uprv_free(newData); return 0; }
|
|
||||||
U_ASSERT(newDataLength <= newDataCapacity);
|
|
||||||
uprv_free(data);
|
|
||||||
data = newData;
|
|
||||||
diff -ru icu.orig/source/i18n/rbt_pars.cpp icu/source/i18n/rbt_pars.cpp
|
|
||||||
--- icu.orig/source/i18n/rbt_pars.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/i18n/rbt_pars.cpp 2021-08-18 16:03:45.537119292 +0200
|
|
||||||
@@ -557,6 +557,7 @@
|
|
||||||
// The next character MUST be a segment open
|
|
||||||
if (single == NULL ||
|
|
||||||
!ICU_Utility::parseChar(rule, iref, SEGMENT_OPEN)) {
|
|
||||||
+ delete single;
|
|
||||||
return syntaxError(U_INVALID_FUNCTION, rule, start, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
diff -ru icu.orig/source/i18n/tridpars.cpp icu/source/i18n/tridpars.cpp
|
|
||||||
--- icu.orig/source/i18n/tridpars.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/i18n/tridpars.cpp 2021-08-18 16:08:57.727071891 +0200
|
|
||||||
@@ -136,6 +136,9 @@
|
|
||||||
specsB = parseFilterID(id, pos, TRUE);
|
|
||||||
// Must close with a ')'
|
|
||||||
if (specsB == NULL || !ICU_Utility::parseChar(id, pos, CLOSE_REV)) {
|
|
||||||
+ if (specsB != NULL) {
|
|
||||||
+ delete specsB;
|
|
||||||
+ }
|
|
||||||
delete specsA;
|
|
||||||
pos = start;
|
|
||||||
return NULL;
|
|
||||||
diff -ru icu.orig/source/i18n/usearch.cpp icu/source/i18n/usearch.cpp
|
|
||||||
--- icu.orig/source/i18n/usearch.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/i18n/usearch.cpp 2021-08-18 16:19:31.533900708 +0200
|
|
||||||
@@ -222,6 +222,9 @@
|
|
||||||
int32_t *temp = (int32_t *)allocateMemory(
|
|
||||||
sizeof(int32_t) * newlength, status);
|
|
||||||
if (U_FAILURE(*status)) {
|
|
||||||
+ if (temp != NULL) {
|
|
||||||
+ uprv_free(temp);
|
|
||||||
+ }
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
uprv_memcpy(temp, destination, sizeof(int32_t) * (size_t)offset);
|
|
||||||
diff -ru icu.orig/source/i18n/usearch.cpp icu/source/i18n/usearch.cpp
|
|
||||||
--- icu.orig/source/i18n/usearch.cpp 2021-08-18 16:23:27.961337248 +0200
|
|
||||||
+++ icu/source/i18n/usearch.cpp 2021-08-18 16:27:47.140623351 +0200
|
|
||||||
@@ -266,6 +266,9 @@
|
|
||||||
sizeof(int64_t) * newlength, status);
|
|
||||||
|
|
||||||
if (U_FAILURE(*status)) {
|
|
||||||
+ if (temp != NULL) {
|
|
||||||
+ uprv_free(temp);
|
|
||||||
+ }
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff -ru icu.orig/source/i18n/uspoof_impl.cpp icu/source/i18n/uspoof_impl.cpp
|
|
||||||
--- icu.orig/source/i18n/uspoof_impl.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/i18n/uspoof_impl.cpp 2021-08-18 16:30:43.061460025 +0200
|
|
||||||
@@ -196,6 +196,9 @@
|
|
||||||
tmpSet = allowedChars.clone();
|
|
||||||
const char *tmpLocalesList = uprv_strdup(localesList);
|
|
||||||
if (tmpSet == NULL || tmpLocalesList == NULL) {
|
|
||||||
+ if (tmpLocalesList != NULL) {
|
|
||||||
+ uprv_free((void *)tmpLocalesList);
|
|
||||||
+ }
|
|
||||||
status = U_MEMORY_ALLOCATION_ERROR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
diff -ru icu.orig/source/common/loclikely.cpp icu/source/common/loclikely.cpp
|
|
||||||
--- icu.orig/source/common/loclikely.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/loclikely.cpp 2021-08-18 16:59:05.786257032 +0200
|
|
||||||
@@ -1351,7 +1351,9 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- rgBuf[rgLen] = 0;
|
|
||||||
+ if (rgLen >= 0) {
|
|
||||||
+ rgBuf[rgLen] = 0;
|
|
||||||
+ }
|
|
||||||
uprv_strncpy(region, rgBuf, regionCapacity);
|
|
||||||
return u_terminateChars(region, regionCapacity, rgLen, status);
|
|
||||||
}
|
|
||||||
diff -ru icu.orig/source/common/lsr.cpp icu/source/common/lsr.cpp
|
|
||||||
--- icu.orig/source/common/lsr.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/lsr.cpp 2021-08-18 17:39:36.706794880 +0200
|
|
||||||
@@ -89,13 +89,15 @@
|
|
||||||
int32_t b = region[1] - '0';
|
|
||||||
if (b < 0 || 9 < b) { return 0; }
|
|
||||||
c = region[2] - '0';
|
|
||||||
- if (c < 0 || 9 < c || region[3] != 0) { return 0; }
|
|
||||||
+ if (uprv_strlen(region) > 3) { return 0; }
|
|
||||||
+ if (c < 0 || 9 < c) { return 0; }
|
|
||||||
return (10 * a + b) * 10 + c + 1;
|
|
||||||
} else { // letters: "DE"
|
|
||||||
a = uprv_upperOrdinal(c);
|
|
||||||
if (a < 0 || 25 < a) { return 0; }
|
|
||||||
int32_t b = uprv_upperOrdinal(region[1]);
|
|
||||||
- if (b < 0 || 25 < b || region[2] != 0) { return 0; }
|
|
||||||
+ if (uprv_strlen(region) > 2) { return 0; }
|
|
||||||
+ if (b < 0 || 25 < b) { return 0; }
|
|
||||||
return 26 * a + b + 1001;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
diff -ru icu.orig/source/tools/toolutil/filetools.cpp icu/source/tools/toolutil/filetools.cpp
|
|
||||||
--- icu.orig/source/tools/toolutil/filetools.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/tools/toolutil/filetools.cpp 2021-08-19 09:56:56.393333089 +0200
|
|
||||||
@@ -64,6 +64,7 @@
|
|
||||||
newpath.append(dirEntry->d_name, -1, status);
|
|
||||||
if (U_FAILURE(status)) {
|
|
||||||
fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, u_errorName(status));
|
|
||||||
+ closedir(pDir);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
diff -ru icu.orig/source/tools/pkgdata/pkgtypes.c icu/source/tools/pkgdata/pkgtypes.c
|
|
||||||
--- icu.orig/source/tools/pkgdata/pkgtypes.c 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/tools/pkgdata/pkgtypes.c 2021-08-19 10:37:07.400622046 +0200
|
|
||||||
@@ -30,6 +30,7 @@
|
|
||||||
{
|
|
||||||
int32_t ln = 0;
|
|
||||||
char buffer[1024];
|
|
||||||
+ char *bufferp = buffer;
|
|
||||||
while(l != NULL)
|
|
||||||
{
|
|
||||||
if(l->str)
|
|
||||||
@@ -42,7 +43,7 @@
|
|
||||||
buffer[uprv_strlen(buffer)-1] = '\0';
|
|
||||||
}
|
|
||||||
if(buffer[0] == '"') {
|
|
||||||
- uprv_strcpy(buffer, buffer+1);
|
|
||||||
+ bufferp = buffer+1;
|
|
||||||
}
|
|
||||||
} else if(quote > 0) { /* add quotes */
|
|
||||||
if(l->str[0] != '"') {
|
|
||||||
@@ -53,7 +54,7 @@
|
|
||||||
uprv_strcat(buffer, "\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- T_FileStream_write(s, buffer, (int32_t)uprv_strlen(buffer));
|
|
||||||
+ T_FileStream_write(s, bufferp, (int32_t)uprv_strlen(bufferp));
|
|
||||||
|
|
||||||
ln += (int32_t)uprv_strlen(l->str);
|
|
||||||
}
|
|
||||||
@@ -74,7 +75,8 @@
|
|
||||||
|
|
||||||
const char *pkg_writeCharList(FileStream *s, CharList *l, const char *delim, int32_t quote)
|
|
||||||
{
|
|
||||||
- char buffer[1024];
|
|
||||||
+ char buffer[1026]; /* 1026 instead of 1024 because quotes may be added */
|
|
||||||
+ char *bufferp = buffer;
|
|
||||||
while(l != NULL)
|
|
||||||
{
|
|
||||||
if(l->str)
|
|
||||||
@@ -92,7 +94,7 @@
|
|
||||||
buffer[uprv_strlen(buffer)-1] = '\0';
|
|
||||||
}
|
|
||||||
if(buffer[0] == '"') {
|
|
||||||
- uprv_strcpy(buffer, buffer+1);
|
|
||||||
+ bufferp = buffer+1;
|
|
||||||
}
|
|
||||||
} else if(quote > 0) { /* add quotes */
|
|
||||||
if(l->str[0] != '"') {
|
|
||||||
@@ -103,7 +105,7 @@
|
|
||||||
uprv_strcat(buffer, "\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- T_FileStream_write(s, buffer, (int32_t)uprv_strlen(buffer));
|
|
||||||
+ T_FileStream_write(s, bufferp, (int32_t)uprv_strlen(bufferp));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(l->next && delim)
|
|
||||||
diff -ru icu.orig/source/tools/pkgdata/pkgdata.cpp icu/source/tools/pkgdata/pkgdata.cpp
|
|
||||||
--- icu.orig/source/tools/pkgdata/pkgdata.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/tools/pkgdata/pkgdata.cpp 2021-08-19 11:11:35.563339463 +0200
|
|
||||||
@@ -980,12 +980,12 @@
|
|
||||||
version_major);
|
|
||||||
#else
|
|
||||||
if (noVersion && !reverseExt) {
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION_TMP], "%s%s%s",
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
|
|
||||||
libFileNames[LIB_FILE],
|
|
||||||
FILE_SUFFIX,
|
|
||||||
pkgDataFlags[SOBJ_EXT]);
|
|
||||||
} else {
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION_TMP], "%s%s%s%s%s",
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s%s%s",
|
|
||||||
libFileNames[LIB_FILE],
|
|
||||||
FILE_SUFFIX,
|
|
||||||
reverseExt ? version : pkgDataFlags[SOBJ_EXT],
|
|
||||||
@@ -994,24 +994,24 @@
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (noVersion && !reverseExt) {
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION_MAJOR], "%s%s%s",
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_MAJOR]), "%s%s%s",
|
|
||||||
libFileNames[LIB_FILE],
|
|
||||||
FILE_SUFFIX,
|
|
||||||
pkgDataFlags[SO_EXT]);
|
|
||||||
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION], "%s%s%s",
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s",
|
|
||||||
libFileNames[LIB_FILE],
|
|
||||||
FILE_SUFFIX,
|
|
||||||
pkgDataFlags[SO_EXT]);
|
|
||||||
} else {
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION_MAJOR], "%s%s%s%s%s",
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_MAJOR]), "%s%s%s%s%s",
|
|
||||||
libFileNames[LIB_FILE],
|
|
||||||
FILE_SUFFIX,
|
|
||||||
reverseExt ? version_major : pkgDataFlags[SO_EXT],
|
|
||||||
FILE_EXTENSION_SEP,
|
|
||||||
reverseExt ? pkgDataFlags[SO_EXT] : version_major);
|
|
||||||
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION], "%s%s%s%s%s",
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s%s%s",
|
|
||||||
libFileNames[LIB_FILE],
|
|
||||||
FILE_SUFFIX,
|
|
||||||
reverseExt ? version : pkgDataFlags[SO_EXT],
|
|
||||||
@@ -1029,7 +1029,7 @@
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(IN_STATIC_MODE(mode)) {
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION], "%s.%s", libFileNames[LIB_FILE], pkgDataFlags[A_EXT]);
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s.%s", libFileNames[LIB_FILE], pkgDataFlags[A_EXT]);
|
|
||||||
libFileNames[LIB_FILE_VERSION_MAJOR][0]=0;
|
|
||||||
if(o->verbose) {
|
|
||||||
fprintf(stdout, "# libFileName[LIB_FILE_VERSION] = %s (static)\n", libFileNames[LIB_FILE_VERSION]);
|
|
||||||
@@ -1308,7 +1308,7 @@
|
|
||||||
* archive file suffix is the same, then the final library needs to be archived.
|
|
||||||
*/
|
|
||||||
if (uprv_strcmp(pkgDataFlags[SOBJ_EXT], pkgDataFlags[SO_EXT]) != 0 && uprv_strcmp(pkgDataFlags[A_EXT], pkgDataFlags[SO_EXT]) == 0) {
|
|
||||||
- sprintf(libFileNames[LIB_FILE_VERSION], "%s%s%s.%s",
|
|
||||||
+ snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s.%s",
|
|
||||||
libFileNames[LIB_FILE],
|
|
||||||
pkgDataFlags[LIB_EXT_ORDER][0] == '.' ? "." : "",
|
|
||||||
reverseExt ? version : pkgDataFlags[SO_EXT],
|
|
||||||
diff -ru icu.orig/source/tools/ctestfw/ctest.c icu/source/tools/ctestfw/ctest.c
|
|
||||||
--- icu.orig/source/tools/ctestfw/ctest.c 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/tools/ctestfw/ctest.c 2021-08-19 13:19:21.016799737 +0200
|
|
||||||
@@ -686,7 +686,6 @@
|
|
||||||
}
|
|
||||||
vfprintf(stdout, pattern, ap);
|
|
||||||
fflush(stdout);
|
|
||||||
- va_end(ap);
|
|
||||||
if((*pattern==0) || (pattern[strlen(pattern)-1]!='\n')) {
|
|
||||||
HANGING_OUTPUT=1;
|
|
||||||
} else {
|
|
||||||
@@ -728,7 +727,6 @@
|
|
||||||
}
|
|
||||||
vfprintf(stdout, pattern, ap);
|
|
||||||
fflush(stdout);
|
|
||||||
- va_end(ap);
|
|
||||||
if((*pattern==0) || (pattern[strlen(pattern)-1]!='\n')) {
|
|
||||||
HANGING_OUTPUT=1;
|
|
||||||
} else {
|
|
||||||
@@ -777,7 +775,6 @@
|
|
||||||
}
|
|
||||||
vfprintf(stdout, pattern, ap);
|
|
||||||
fflush(stdout);
|
|
||||||
- va_end(ap);
|
|
||||||
GLOBAL_PRINT_COUNT++;
|
|
||||||
if((*pattern==0) || (pattern[strlen(pattern)-1]!='\n')) {
|
|
||||||
HANGING_OUTPUT=1;
|
|
||||||
@@ -803,6 +800,7 @@
|
|
||||||
}
|
|
||||||
va_start(ap, pattern);
|
|
||||||
vlog_err(NULL, pattern, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
UBool T_CTEST_EXPORT2
|
|
||||||
@@ -806,8 +806,11 @@
|
|
||||||
UBool T_CTEST_EXPORT2
|
|
||||||
log_knownIssue(const char *ticket, const char *pattern, ...) {
|
|
||||||
va_list ap;
|
|
||||||
+ UBool result;
|
|
||||||
va_start(ap, pattern);
|
|
||||||
- return vlog_knownIssue(ticket, pattern, ap);
|
|
||||||
+ result = vlog_knownIssue(ticket, pattern, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
+ return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void T_CTEST_EXPORT2
|
|
||||||
@@ -843,6 +842,7 @@
|
|
||||||
}
|
|
||||||
vlog_err(NULL, pattern, ap); /* no need for prefix in default case */
|
|
||||||
}
|
|
||||||
+ va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void T_CTEST_EXPORT2
|
|
||||||
@@ -852,6 +852,7 @@
|
|
||||||
|
|
||||||
va_start(ap, pattern);
|
|
||||||
vlog_info(NULL, pattern, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void T_CTEST_EXPORT2
|
|
||||||
@@ -861,6 +862,7 @@
|
|
||||||
|
|
||||||
va_start(ap, pattern);
|
|
||||||
vlog_verbose(NULL, pattern, ap);
|
|
||||||
+ va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -882,6 +884,7 @@
|
|
||||||
} else {
|
|
||||||
vlog_info("[DATA] ", pattern, ap);
|
|
||||||
}
|
|
||||||
+ va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
diff -ru icu/source/tools/gensprep/store.c icu.new/source/tools/gensprep/store.c
|
|
||||||
--- icu/source/tools/gensprep/store.c 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu.new/source/tools/gensprep/store.c 2021-08-19 16:16:17.213687755 +0200
|
|
||||||
@@ -636,7 +636,6 @@
|
|
||||||
cleanUpData(void) {
|
|
||||||
uprv_free(mappingData);
|
|
||||||
utrie_close(sprepTrie);
|
|
||||||
- uprv_free(sprepTrie);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* #if !UCONFIG_NO_IDNA */
|
|
||||||
diff -ru icu.orig/source/common/uloc_tag.cpp icu/source/common/uloc_tag.cpp
|
|
||||||
--- icu.orig/source/common/uloc_tag.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/uloc_tag.cpp 2021-08-19 16:32:26.948185554 +0200
|
|
||||||
@@ -2254,6 +2254,7 @@
|
|
||||||
var = (VariantListEntry*)uprv_malloc(sizeof(VariantListEntry));
|
|
||||||
if (var == NULL) {
|
|
||||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
|
||||||
+ uprv_free(pExtension);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*pSep = 0;
|
|
||||||
diff -ru icu.orig/source/common/uloc_keytype.cpp icu/source/common/uloc_keytype.cpp
|
|
||||||
--- icu.orig/source/common/uloc_keytype.cpp 2021-08-19 16:34:07.037514442 +0200
|
|
||||||
+++ icu/source/common/uloc_keytype.cpp 2021-08-19 16:37:38.276098078 +0200
|
|
||||||
@@ -325,6 +325,10 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (U_FAILURE(sts)) {
|
|
||||||
+ if (typeDataMap != NULL) {
|
|
||||||
+ uhash_close(typeDataMap);
|
|
||||||
+ typeDataMap = NULL;
|
|
||||||
+ }
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff -ru icu.orig/source/common/serv.cpp icu/source/common/serv.cpp
|
|
||||||
--- icu.orig/source/common/serv.cpp 2021-08-19 20:45:49.923742619 +0200
|
|
||||||
+++ icu/source/common/serv.cpp 2021-08-20 13:16:04.401298668 +0200
|
|
||||||
@@ -793,6 +793,7 @@
|
|
||||||
*/
|
|
||||||
int32_t pos = UHASH_FIRST;
|
|
||||||
const UHashElement *entry = NULL;
|
|
||||||
+ /* coverity[deref_after_free] */
|
|
||||||
while ((entry = dnCache->cache.nextElement(pos)) != NULL) {
|
|
||||||
const UnicodeString* id = (const UnicodeString*)entry->value.pointer;
|
|
||||||
if (matchKey != NULL && !matchKey->isFallbackOf(*id)) {
|
|
||||||
diff -ru icu.orig/source/i18n/decNumber.h icu/source/i18n/decNumber.h
|
|
||||||
--- icu.orig/source/i18n/decNumber.h 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/i18n/decNumber.h 2021-08-20 13:17:27.208783404 +0200
|
|
||||||
@@ -86,7 +86,7 @@
|
|
||||||
/* range: -1999999997 through 999999999 */
|
|
||||||
uint8_t bits; /* Indicator bits (see above) */
|
|
||||||
/* Coefficient, from least significant unit */
|
|
||||||
- decNumberUnit lsu[DECNUMUNITS];
|
|
||||||
+ decNumberUnit lsu[DECNUMUNITS+2];
|
|
||||||
} decNumber;
|
|
||||||
|
|
||||||
/* Notes: */
|
|
||||||
diff -ru icu.orig/source/tools/makeconv/genmbcs.cpp icu/source/tools/makeconv/genmbcs.cpp
|
|
||||||
--- icu.orig/source/tools/makeconv/genmbcs.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/tools/makeconv/genmbcs.cpp 2021-08-23 08:07:02.972087418 +0200
|
|
||||||
@@ -172,7 +172,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
MBCSInit(mbcsData, ucm);
|
|
||||||
- return &mbcsData->newConverter;
|
|
||||||
+ return (NewConverter *)mbcsData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
diff -ru icu.orig/source/common/brkiter.cpp icu/source/common/brkiter.cpp
|
|
||||||
--- icu.orig/source/common/brkiter.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/brkiter.cpp 2021-08-23 13:56:11.644603960 +0200
|
|
||||||
@@ -105,7 +105,9 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /* coverity[incorrect_free] */
|
|
||||||
ures_close(brkRules);
|
|
||||||
+ /* coverity[incorrect_free] */
|
|
||||||
ures_close(brkName);
|
|
||||||
|
|
||||||
UDataMemory* file = udata_open(U_ICUDATA_BRKITR, ext, fnbuff, &status);
|
|
||||||
diff -ru icu.orig/source/common/uresbund.cpp icu/source/common/uresbund.cpp
|
|
||||||
--- icu.orig/source/common/uresbund.cpp 2020-04-22 22:04:20.000000000 +0200
|
|
||||||
+++ icu/source/common/uresbund.cpp 2021-08-23 13:56:53.329339657 +0200
|
|
||||||
@@ -2493,7 +2493,9 @@
|
|
||||||
static void U_CALLCONV
|
|
||||||
ures_loc_closeLocales(UEnumeration *enumerator) {
|
|
||||||
ULocalesContext *ctx = (ULocalesContext *)enumerator->context;
|
|
||||||
+ /* coverity[address_free] */
|
|
||||||
ures_close(&ctx->curr);
|
|
||||||
+ /* coverity[address_free] */
|
|
||||||
ures_close(&ctx->installed);
|
|
||||||
uprv_free(ctx);
|
|
||||||
uprv_free(enumerator);
|
|
@ -0,0 +1,171 @@
|
|||||||
|
diff -urN icu.old/source/common/uloc_keytype.cpp icu/source/common/uloc_keytype.cpp
|
||||||
|
--- icu.old/source/common/uloc_keytype.cpp 2017-02-01 01:21:30.000000000 +0530
|
||||||
|
+++ icu/source/common/uloc_keytype.cpp 2018-09-23 18:48:04.414990551 +0530
|
||||||
|
@@ -383,6 +383,7 @@
|
||||||
|
LocExtKeyData* keyData = (LocExtKeyData*)uprv_malloc(sizeof(LocExtKeyData));
|
||||||
|
if (keyData == NULL) {
|
||||||
|
sts = U_MEMORY_ALLOCATION_ERROR;
|
||||||
|
+ uprv_free(typeDataMap);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
keyData->bcpId = bcpKeyId;
|
||||||
|
diff -urN icu.old/source/common/uloc_tag.cpp icu/source/common/uloc_tag.cpp
|
||||||
|
--- icu.old/source/common/uloc_tag.cpp 2017-10-11 21:54:34.000000000 +0530
|
||||||
|
+++ icu/source/common/uloc_tag.cpp 2018-09-23 18:48:58.207182317 +0530
|
||||||
|
@@ -2145,6 +2145,7 @@
|
||||||
|
|
||||||
|
error:
|
||||||
|
ultag_close(t);
|
||||||
|
+ uprv_free(pExtension);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urN icu.old/source/i18n/olsontz.cpp icu/source/i18n/olsontz.cpp
|
||||||
|
--- icu.old/source/i18n/olsontz.cpp 2017-02-01 01:21:27.000000000 +0530
|
||||||
|
+++ icu/source/i18n/olsontz.cpp 2018-09-23 18:52:02.140418739 +0530
|
||||||
|
@@ -787,6 +787,7 @@
|
||||||
|
if (historicRules[typeIdx] == NULL) {
|
||||||
|
status = U_MEMORY_ALLOCATION_ERROR;
|
||||||
|
deleteTransitionRules();
|
||||||
|
+ uprv_free(times);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff -urN icu.old/source/i18n/rbt_pars.cpp icu/source/i18n/rbt_pars.cpp
|
||||||
|
--- icu.old/source/i18n/rbt_pars.cpp 2017-02-01 01:21:27.000000000 +0530
|
||||||
|
+++ icu/source/i18n/rbt_pars.cpp 2018-09-23 18:52:51.362679180 +0530
|
||||||
|
@@ -557,6 +557,7 @@
|
||||||
|
// The next character MUST be a segment open
|
||||||
|
if (single == NULL ||
|
||||||
|
!ICU_Utility::parseChar(rule, iref, SEGMENT_OPEN)) {
|
||||||
|
+ uprv_free(single);
|
||||||
|
return syntaxError(U_INVALID_FUNCTION, rule, start, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urN icu.old/source/i18n/tznames_impl.cpp icu/source/i18n/tznames_impl.cpp
|
||||||
|
--- icu.old/source/i18n/tznames_impl.cpp 2017-10-11 21:54:34.000000000 +0530
|
||||||
|
+++ icu/source/i18n/tznames_impl.cpp 2018-09-23 18:55:36.222152997 +0530
|
||||||
|
@@ -1762,6 +1762,7 @@
|
||||||
|
UResourceBundle* rbTable = NULL;
|
||||||
|
rbTable = ures_getByKey(rb, key, rbTable, &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
+ uprv_free(rbTable);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1784,6 +1785,7 @@
|
||||||
|
if (names != NULL) {
|
||||||
|
uprv_free(names);
|
||||||
|
}
|
||||||
|
+ uprv_free(rbTable);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urN icu.old/source/i18n/usearch.cpp icu/source/i18n/usearch.cpp
|
||||||
|
--- icu.old/source/i18n/usearch.cpp 2017-02-01 01:21:27.000000000 +0530
|
||||||
|
+++ icu/source/i18n/usearch.cpp 2018-09-23 18:54:34.752103865 +0530
|
||||||
|
@@ -222,6 +222,7 @@
|
||||||
|
int32_t *temp = (int32_t *)allocateMemory(
|
||||||
|
sizeof(int32_t) * newlength, status);
|
||||||
|
if (U_FAILURE(*status)) {
|
||||||
|
+ uprv_free(temp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
uprv_memcpy(temp, destination, sizeof(int32_t) * (size_t)offset);
|
||||||
|
@@ -263,6 +264,7 @@
|
||||||
|
sizeof(int64_t) * newlength, status);
|
||||||
|
|
||||||
|
if (U_FAILURE(*status)) {
|
||||||
|
+ uprv_free(temp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -urN icu.old/source/tools/ctestfw/ctest.c icu/source/tools/ctestfw/ctest.c
|
||||||
|
--- icu.old/source/tools/ctestfw/ctest.c 2017-02-01 01:21:30.000000000 +0530
|
||||||
|
+++ icu/source/tools/ctestfw/ctest.c 2018-09-23 18:19:43.612734248 +0530
|
||||||
|
@@ -803,6 +803,7 @@
|
||||||
|
}
|
||||||
|
va_start(ap, pattern);
|
||||||
|
vlog_err(NULL, pattern, ap);
|
||||||
|
+ va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
UBool T_CTEST_EXPORT2
|
||||||
|
@@ -810,6 +811,7 @@
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pattern);
|
||||||
|
return vlog_knownIssue(ticket, pattern, ap);
|
||||||
|
+ va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void T_CTEST_EXPORT2
|
||||||
|
@@ -843,6 +845,7 @@
|
||||||
|
}
|
||||||
|
vlog_err(NULL, pattern, ap); /* no need for prefix in default case */
|
||||||
|
}
|
||||||
|
+ va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void T_CTEST_EXPORT2
|
||||||
|
@@ -852,6 +855,7 @@
|
||||||
|
|
||||||
|
va_start(ap, pattern);
|
||||||
|
vlog_info(NULL, pattern, ap);
|
||||||
|
+ va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void T_CTEST_EXPORT2
|
||||||
|
@@ -861,6 +865,7 @@
|
||||||
|
|
||||||
|
va_start(ap, pattern);
|
||||||
|
vlog_verbose(NULL, pattern, ap);
|
||||||
|
+ va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -882,6 +887,7 @@
|
||||||
|
} else {
|
||||||
|
vlog_info("[DATA] ", pattern, ap);
|
||||||
|
}
|
||||||
|
+ va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
diff -urN icu.old/source/tools/gensprep/store.c icu/source/tools/gensprep/store.c
|
||||||
|
--- icu.old/source/tools/gensprep/store.c 2017-02-08 00:27:35.000000000 +0530
|
||||||
|
+++ icu/source/tools/gensprep/store.c 2018-09-23 17:42:52.262908882 +0530
|
||||||
|
@@ -634,7 +634,6 @@
|
||||||
|
cleanUpData(void) {
|
||||||
|
uprv_free(mappingData);
|
||||||
|
utrie_close(sprepTrie);
|
||||||
|
- uprv_free(sprepTrie);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #if !UCONFIG_NO_IDNA */
|
||||||
|
diff -urN icu.old/source/tools/pkgdata/pkgdata.cpp icu/source/tools/pkgdata/pkgdata.cpp
|
||||||
|
--- icu.old/source/tools/pkgdata/pkgdata.cpp 2017-03-23 04:56:34.000000000 +0530
|
||||||
|
+++ icu/source/tools/pkgdata/pkgdata.cpp 2018-09-23 17:40:19.730240502 +0530
|
||||||
|
@@ -1531,11 +1531,11 @@
|
||||||
|
gencFilePath);
|
||||||
|
|
||||||
|
result = runCommand(cmd);
|
||||||
|
- uprv_free(cmd);
|
||||||
|
if (result != 0) {
|
||||||
|
fprintf(stderr, "Error creating with assembly code. Failed command: %s\n", cmd);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
+ uprv_free(cmd);
|
||||||
|
|
||||||
|
return pkg_generateLibraryFile(targetDir, mode, tempObjectFile);
|
||||||
|
}
|
||||||
|
diff -urN icu.old/source/tools/toolutil/filetools.cpp icu/source/tools/toolutil/filetools.cpp
|
||||||
|
--- icu.old/source/tools/toolutil/filetools.cpp 2017-02-01 01:21:30.000000000 +0530
|
||||||
|
+++ icu/source/tools/toolutil/filetools.cpp 2018-09-23 16:09:47.949491516 +0530
|
||||||
|
@@ -64,6 +64,7 @@
|
||||||
|
newpath.append(dirEntry->d_name, -1, status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, u_errorName(status));
|
||||||
|
+ free(pDir);
|
||||||
|
return FALSE;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,154 @@
|
|||||||
|
Index: icu4c/source/test/intltest/tzregts.cpp
|
||||||
|
===================================================================
|
||||||
|
--- icu4c/source/test/intltest/tzregts.cpp (リビジョン 40953)
|
||||||
|
+++ icu4c/source/test/intltest/tzregts.cpp (リビジョン 40954)
|
||||||
|
@@ -12,6 +12,7 @@
|
||||||
|
#include "unicode/simpletz.h"
|
||||||
|
#include "unicode/smpdtfmt.h"
|
||||||
|
#include "unicode/strenum.h"
|
||||||
|
+#include "unicode/gregocal.h"
|
||||||
|
#include "tzregts.h"
|
||||||
|
#include "calregts.h"
|
||||||
|
#include "cmemory.h"
|
||||||
|
@@ -46,6 +47,7 @@
|
||||||
|
CASE(16, TestJDK12API);
|
||||||
|
CASE(17, Test4176686);
|
||||||
|
CASE(18, Test4184229);
|
||||||
|
+ CASE(19, TestNegativeDaylightSaving);
|
||||||
|
default: name = ""; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -709,10 +711,10 @@
|
||||||
|
int32_t DATA [] = {
|
||||||
|
1, GOOD,
|
||||||
|
0, BAD,
|
||||||
|
- -1, BAD,
|
||||||
|
+ -1, GOOD, // #13566 updates SimpleTimeZone to support negative DST saving amount
|
||||||
|
60*60*1000, GOOD,
|
||||||
|
- INT32_MIN, BAD,
|
||||||
|
- // Integer.MAX_VALUE, ?, // no upper limit on DST savings at this time
|
||||||
|
+ INT32_MAX, GOOD, // no upper limit on DST savings at this time
|
||||||
|
+ INT32_MIN, GOOD // no lower limit as well
|
||||||
|
};
|
||||||
|
|
||||||
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
|
@@ -1206,4 +1208,61 @@
|
||||||
|
delete zone;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void TimeZoneRegressionTest::TestNegativeDaylightSaving() {
|
||||||
|
+ UErrorCode status = U_ZERO_ERROR;
|
||||||
|
+ int32_t stdOff = 1 * 60*60*1000; // Standard offset UTC+1
|
||||||
|
+ int save = -1 * 60*60*1000; // DST saving amount -1 hour
|
||||||
|
+ SimpleTimeZone stzDublin(stdOff, "Dublin-2018",
|
||||||
|
+ UCAL_OCTOBER, -1, -UCAL_SUNDAY, 2*60*60*1000,
|
||||||
|
+ UCAL_MARCH, -1, -UCAL_SUNDAY, 1*60*60*1000,
|
||||||
|
+ save, status);
|
||||||
|
+ failure(status, "SimpleTimeZone constructor");
|
||||||
|
+
|
||||||
|
+ if (save != stzDublin.getDSTSavings()) {
|
||||||
|
+ errln((UnicodeString)"FAIL: DST saving is not " + save);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ GregorianCalendar cal(* TimeZone::getGMT(), status);
|
||||||
|
+ failure(status, "GregorianCalendar constructor");
|
||||||
|
+
|
||||||
|
+ UDate testDate;
|
||||||
|
+ int32_t rawOffset;
|
||||||
|
+ int32_t dstOffset;
|
||||||
|
+
|
||||||
|
+ cal.set(2018, UCAL_JANUARY, 15, 0, 0, 0);
|
||||||
|
+ testDate = cal.getTime(status);
|
||||||
|
+ failure(status, "calendar getTime() - Jan 15");
|
||||||
|
+
|
||||||
|
+ if (!stzDublin.inDaylightTime(testDate, status)) {
|
||||||
|
+ errln("FAIL: The test date (Jan 15) must be in DST.");
|
||||||
|
+ }
|
||||||
|
+ failure(status, "inDaylightTime() - Jan 15");
|
||||||
|
+
|
||||||
|
+ stzDublin.getOffset(testDate, FALSE, rawOffset, dstOffset, status);
|
||||||
|
+ failure(status, "getOffset() - Jan 15");
|
||||||
|
+ if (rawOffset != stdOff || dstOffset != save) {
|
||||||
|
+ errln((UnicodeString)"FAIL: Expected [stdoff=" + stdOff + ",save=" + save
|
||||||
|
+ + "] on the test date (Jan 15), actual[stdoff=" + rawOffset
|
||||||
|
+ + ",save=" + dstOffset + "]");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ cal.set(2018, UCAL_JULY, 15, 0, 0, 0);
|
||||||
|
+ testDate = cal.getTime(status);
|
||||||
|
+ failure(status, "calendar getTime() - Jul 15");
|
||||||
|
+
|
||||||
|
+ if (stzDublin.inDaylightTime(testDate, status)) {
|
||||||
|
+ errln("FAIL: The test date (Jul 15) must be in DST.");
|
||||||
|
+ }
|
||||||
|
+ failure(status, "inDaylightTime() - Jul 15");
|
||||||
|
+
|
||||||
|
+ stzDublin.getOffset(testDate, FALSE, rawOffset, dstOffset, status);
|
||||||
|
+ failure(status, "getOffset() - Jul 15");
|
||||||
|
+ if (rawOffset != stdOff || dstOffset != 0) {
|
||||||
|
+ errln((UnicodeString)"FAIL: Expected [stdoff=" + stdOff + ",save=" + 0
|
||||||
|
+ + "] on the test date (Jul 15), actual[stdoff=" + rawOffset
|
||||||
|
+ + ",save=" + dstOffset + "]");
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||||
|
Index: icu4c/source/test/intltest/tzregts.h
|
||||||
|
===================================================================
|
||||||
|
--- icu4c/source/test/intltest/tzregts.h (リビジョン 40953)
|
||||||
|
+++ icu4c/source/test/intltest/tzregts.h (リビジョン 40954)
|
||||||
|
@@ -49,6 +49,7 @@
|
||||||
|
void TestJDK12API(void);
|
||||||
|
void Test4184229(void);
|
||||||
|
UBool checkCalendar314(GregorianCalendar *testCal, TimeZone *testTZ);
|
||||||
|
+ void TestNegativeDaylightSaving(void);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Index: icu4c/source/i18n/simpletz.cpp
|
||||||
|
===================================================================
|
||||||
|
--- icu4c/source/i18n/simpletz.cpp (リビジョン 40953)
|
||||||
|
+++ icu4c/source/i18n/simpletz.cpp (リビジョン 40954)
|
||||||
|
@@ -177,7 +177,7 @@
|
||||||
|
|
||||||
|
decodeRules(status);
|
||||||
|
|
||||||
|
- if (savingsDST <= 0) {
|
||||||
|
+ if (savingsDST == 0) {
|
||||||
|
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -686,7 +686,7 @@
|
||||||
|
void
|
||||||
|
SimpleTimeZone::setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status)
|
||||||
|
{
|
||||||
|
- if (millisSavedDuringDST <= 0) {
|
||||||
|
+ if (millisSavedDuringDST == 0) {
|
||||||
|
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Index: icu4c/source/i18n/unicode/simpletz.h
|
||||||
|
===================================================================
|
||||||
|
--- icu4c/source/i18n/unicode/simpletz.h (リビジョン 40953)
|
||||||
|
+++ icu4c/source/i18n/unicode/simpletz.h (リビジョン 40954)
|
||||||
|
@@ -647,7 +647,8 @@
|
||||||
|
* Sets the amount of time in ms that the clock is advanced during DST.
|
||||||
|
* @param millisSavedDuringDST the number of milliseconds the time is
|
||||||
|
* advanced with respect to standard time when the daylight savings rules
|
||||||
|
- * are in effect. A positive number, typically one hour (3600000).
|
||||||
|
+ * are in effect. Typically one hour (+3600000). The amount could be negative,
|
||||||
|
+ * but not 0.
|
||||||
|
* @param status An UErrorCode to receive the status.
|
||||||
|
* @stable ICU 2.0
|
||||||
|
*/
|
||||||
|
@@ -657,7 +658,8 @@
|
||||||
|
* Returns the amount of time in ms that the clock is advanced during DST.
|
||||||
|
* @return the number of milliseconds the time is
|
||||||
|
* advanced with respect to standard time when the daylight savings rules
|
||||||
|
- * are in effect. A positive number, typically one hour (3600000).
|
||||||
|
+ * are in effect. Typically one hour (+3600000). The amount could be negative,
|
||||||
|
+ * but not 0.
|
||||||
|
* @stable ICU 2.0
|
||||||
|
*/
|
||||||
|
virtual int32_t getDSTSavings(void) const;
|
Loading…
Reference in new issue