]> granicus.if.org Git - icu/commitdiff
ICU-21249 Adds error code check to prevent segmentation fault if release-68-alpha
authorNorbert Runge <41129501+gnrunge@users.noreply.github.com>
Fri, 2 Oct 2020 03:35:10 +0000 (03:35 +0000)
committerNorbert Runge <41129501+gnrunge@users.noreply.github.com>
Fri, 2 Oct 2020 16:57:19 +0000 (09:57 -0700)
See #1356

icu4c/source/test/cintltst/unumberrangeformattertst.c

index 823847363f533251576afef9ca006aedcc7626e5..35c21a2a5108dad51f597e9a21ddd38add0a03cd 100644 (file)
@@ -65,10 +65,10 @@ static void TestExampleCode() {
     // Get the result string:
     int32_t len;
     const UChar* str = ufmtval_getString(unumrf_resultAsValue(uresult, &ec), &len, &ec);
-    if (assertSuccessCheck("There should not be a failure in the example code", &ec, TRUE)) {
-        assertUEquals("Should produce expected string result", u"$3 – $5", str);
-        assertIntEquals("Length should be as expected", u_strlen(str), len);
-    }
+    assertSuccessCheck("There should not be a failure in the example code", &ec, TRUE);
+    assertUEquals("Should produce expected string result", u"$3 – $5", str);
+    int32_t resultLength = str != NULL ? u_strlen(str) : 0;
+    assertIntEquals("Length should be as expected", resultLength, len);
 
     // Cleanup:
     unumrf_close(uformatter);