From: Greg Woolsey Date: Sat, 16 Mar 2019 06:55:16 +0000 (+0000) Subject: Handle possible invalid date value (#61652) X-Git-Tag: REL_4_1_0~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ee83ce5fcd19ae18713bfbcf9d6f508aff466eeb;p=poi.git Handle possible invalid date value (#61652) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1855627 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/formula/functions/EDate.java b/src/java/org/apache/poi/ss/formula/functions/EDate.java index d4998b84b4..3faec3dd84 100644 --- a/src/java/org/apache/poi/ss/formula/functions/EDate.java +++ b/src/java/org/apache/poi/ss/formula/functions/EDate.java @@ -45,6 +45,9 @@ public class EDate implements FreeRefFunction { int offsetInMonthAsNumber = (int) getValue(args[1]); Date startDate = DateUtil.getJavaDate(startDateAsNumber); + if (startDate == null) { + return ErrorEval.VALUE_INVALID; + } Calendar calendar = LocaleUtil.getLocaleCalendar(); calendar.setTime(startDate); calendar.add(Calendar.MONTH, offsetInMonthAsNumber);