From: Krzysztof Wicher Date: Fri, 19 Jan 2018 00:58:15 +0000 (-0800) Subject: Do not throw IndexOutOfBounds when AM/PM designator is empty (#15904) X-Git-Tag: accepted/tizen/base/20180629.140029~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=734a8d7612237b4fab066957318345b5b7b157fe;p=platform%2Fupstream%2Fcoreclr.git Do not throw IndexOutOfBounds when AM/PM designator is empty (#15904) * do not throw IndexOutOfBounds when AM/PM designator is empty * store am/pm designator in local --- diff --git a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs index cbf9094..40962f8 100644 --- a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs +++ b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs @@ -3607,15 +3607,18 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // change the code below. if (str.GetNext()) { - if (str.GetChar() == dtfi.AMDesignator[0]) + string amDesignator = dtfi.AMDesignator; + if (amDesignator.Length > 0 && str.GetChar() == amDesignator[0]) { result = TM.AM; - return (true); + return true; } - if (str.GetChar() == dtfi.PMDesignator[0]) + + string pmDesignator = dtfi.PMDesignator; + if (pmDesignator.Length > 0 && str.GetChar() == pmDesignator[0]) { result = TM.PM; - return (true); + return true; } } return false;