From: Norbert Runge <41129501+gnrunge@users.noreply.github.com> Date: Fri, 2 Oct 2020 03:35:10 +0000 (+0000) Subject: ICU-21249 Adds error code check to prevent segmentation fault if X-Git-Tag: release-68-alpha X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c0d4065607b9edde49a6799e609a33b87fe4409f;p=icu ICU-21249 Adds error code check to prevent segmentation fault if See #1356 --- diff --git a/icu4c/source/test/cintltst/unumberrangeformattertst.c b/icu4c/source/test/cintltst/unumberrangeformattertst.c index 823847363f5..35c21a2a510 100644 --- a/icu4c/source/test/cintltst/unumberrangeformattertst.c +++ b/icu4c/source/test/cintltst/unumberrangeformattertst.c @@ -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);