We're updating the issue view to help you get more done. 

SimpleDateFormat::getNumberFormatForField may return an undefined pointer.

Description

If one passes a non-existent field to getNumberFormatForField, it will silently return a wild pointer. This method first calls DateFormatSymbols::getPatternCharIndex(field) which returns UDAT_FIELD_COUNT. Then getNumberFormatForField uses this to index into the fNumberFormatters array which contains only UDAT_FIELD_COUNT pointers. So getNumberFormatForField returns whatever happens to be at the end of that array in memory.

Expected behavior: getNumberFormatForField ought to return NULL if it is passed a bad field value.

Environment

Status

Assignee

TracBot

Reporter

TracBot

tracCreated

Sep 22, 2014, 9:58 PM

tracOwner

tkeep

tracProject

ICU4C

tracReporter

tkeep

tracResolution

fixed

tracReviewer

yoshito

tracStatus

closed

Components

Fix versions

Priority

critical