From b05470083a5a6f35a2c820500c823afadba804f0 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 13 Nov 2018 08:14:57 +0100 Subject: Don't call Date's ImpYearToDays with zero year argument ...on which it asserts since 6d4f2dcc7cbba771e9d9b00de50368db4a88ef1b "Resolves: tdf#100452 class Date full (BCE,CE) proleptic Gregorian calendar". The assert fired when executing the Basic code from attachment 146529 to "FileDateTime("\\nonexistent\smb\path") returns bogus result rather than throwing error": > #4 0x00007ffff1d1c830 in (anonymous namespace)::ImpYearToDays(short) (nYear=0) at tools/source/datetime/tdate.cxx:55 > #5 0x00007ffff1d1c449 in Date::DateToDays(unsigned short, unsigned short, short) (nDay=0, nMonth=0, nYear=0) at tools/source/datetime/tdate.cxx:149 > #6 0x00007ffff1d1c3e5 in Date::GetAsNormalizedDays() const (this=0x7fffffff7268) at tools/source/datetime/tdate.cxx:142 > #7 0x00007ffff1d1dae5 in operator-(Date const&, Date const&) (rDate1=1900-1-1, rDate2=0-0-0) at tools/source/datetime/tdate.cxx:581 > #8 0x00007ffff5f87347 in GetDayDiff(Date const&) (rDate=0-0-0) at basic/source/runtime/methods.cxx:4653 > #9 0x00007ffff5f8aebb in SbRtl_FileDateTime(StarBASIC*, SbxArray&, bool) (rPar=...) at basic/source/runtime/methods.cxx:3054 Change-Id: I6468eeafc3daf325d3da3dfeacd08c7df1d1a8f4 Reviewed-on: https://gerrit.libreoffice.org/63318 Tested-by: Jenkins Reviewed-by: Eike Rathke --- basic/source/runtime/methods.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'basic') diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 6d10a1a92edd..20348c850839 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -3051,7 +3051,7 @@ void SbRtl_FileDateTime(StarBASIC *, SbxArray & rPar, bool) aDate = Date( aDT.Day, aDT.Month, aDT.Year ); } - double fSerial = static_cast(GetDayDiff( aDate )); + double fSerial = aDate.IsEmpty() ? 0 : static_cast(GetDayDiff( aDate )); long nSeconds = aTime.GetHour(); nSeconds *= 3600; nSeconds += aTime.GetMin() * 60; -- cgit