Imported Upstream version 58.1
[platform/upstream/icu.git] / source / i18n / fpositer.cpp
index 3481252..eb405f9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 ******************************************************************************
 * Copyright (C) 2009-2012, International Business Machines Corporation and
@@ -60,7 +62,10 @@ void FieldPositionIterator::setData(UVector32 *adopt, UErrorCode& status) {
   // Verify that adopt has valid data, and update status if it doesn't.
   if (U_SUCCESS(status)) {
     if (adopt) {
-      if ((adopt->size() % 3) != 0) {
+      if (adopt->size() == 0) {
+        delete adopt;
+        adopt = NULL;
+      } else if ((adopt->size() % 3) != 0) {
         status = U_ILLEGAL_ARGUMENT_ERROR;
       } else {
         for (int i = 1; i < adopt->size(); i += 3) {