]> granicus.if.org Git - icu/commitdiff
ICU-9115 ubrk_setText does not check the input (Null check)
authorJungshik Shin <jshin@chromium.org>
Wed, 15 Feb 2012 00:41:48 +0000 (00:41 +0000)
committerJungshik Shin <jshin@chromium.org>
Wed, 15 Feb 2012 00:41:48 +0000 (00:41 +0000)
X-SVN-Rev: 31397

icu4c/source/common/ubrk.cpp

index f6a70efeeae8ec0cfecd23eeb566f1db1a21d5de..be012373c10be9cb53b7053d37e28e5987d49958 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ********************************************************************************
-*   Copyright (C) 1996-2011, International Business Machines
+*   Copyright (C) 1996-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 ********************************************************************************
 */
@@ -166,6 +166,12 @@ ubrk_setText(UBreakIterator* bi,
              int32_t         textLength,
              UErrorCode*     status)
 {
+    if (bi == NULL) {
+        if (U_SUCCESS(*status)) {
+            *status = U_ILLEGAL_ARGUMENT_ERROR;
+        }
+        return;
+    }
     BreakIterator *brit = (BreakIterator *)bi;
     UText  ut = UTEXT_INITIALIZER;
     utext_openUChars(&ut, text, textLength, status);
@@ -181,6 +187,12 @@ ubrk_setUText(UBreakIterator *bi,
              UText          *text,
              UErrorCode     *status)
 {
+    if (bi == NULL) {
+        if (U_SUCCESS(*status)) {
+            *status = U_ILLEGAL_ARGUMENT_ERROR;
+        }
+        return;
+    }
     RuleBasedBreakIterator *brit = (RuleBasedBreakIterator *)bi;
     brit->RuleBasedBreakIterator::setText(text, *status);
 }