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 8238473..35c21a2 100644
--- a/icu4c/source/test/cintltst/unumberrangeformattertst.c
+++ b/icu4c/source/test/cintltst/unumberrangeformattertst.c
@@ -65,10 +65,10 @@
// 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);