mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-66 Moved the deletion to after the comparison
X-SVN-Rev: 3648
This commit is contained in:
parent
8947e594c3
commit
a06988ae1c
1 changed files with 6 additions and 3 deletions
|
@ -706,18 +706,21 @@ int32_t Calendar::stringToDayNumber(const UnicodeString& string, UErrorCode& sta
|
|||
|
||||
int32_t len = string.length();
|
||||
char *number = new char[1 + len];
|
||||
if (number == 0) { status = U_MEMORY_ALLOCATION_ERROR; return 0; }
|
||||
if (number == 0) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
char *end;
|
||||
|
||||
string.extract(0, len, number);
|
||||
number[len] = 0;
|
||||
int32_t value = strtol(number, &end, 10); // Radix 10
|
||||
|
||||
delete[] number;
|
||||
|
||||
if (end-number != len || len == 0 || value < 1 || value > 7)
|
||||
status = U_INVALID_FORMAT_ERROR;
|
||||
|
||||
delete[] number;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue