ICU-3659 assert values are in range before using them to index arrays

X-SVN-Rev: 15493
This commit is contained in:
Alan Liu 2004-05-24 05:59:54 +00:00
parent 046c30de34
commit d08db4a33f

View File

@ -42,6 +42,7 @@
#include "uprops.h"
#include "gregoimp.h"
#include "cstring.h"
#include "uassert.h"
#include <float.h>
#if defined( U_DEBUG_CALSVC ) || defined (U_DEBUG_CAL)
@ -581,6 +582,10 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
if (U_FAILURE(status)) {
return;
}
// assert values are in range before using them to index arrays
U_ASSERT(field == UDAT_YEAR_FIELD || field == UDAT_YEAR_WOY_FIELD ||
(value >= cal.getMinimum(field) &&
value <= cal.getMaximum(field)));
switch (patternCharIndex) {