Kaydet (Commit) b0547008 authored tarafından Stephan Bergmann's avatar Stephan Bergmann Kaydeden (comit) Eike Rathke

Don't call Date's ImpYearToDays with zero year argument

...on which it asserts since 6d4f2dcc "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: 's avatarEike Rathke <erack@redhat.com>
üst d1401579
......@@ -3051,7 +3051,7 @@ void SbRtl_FileDateTime(StarBASIC *, SbxArray & rPar, bool)
aDate = Date( aDT.Day, aDT.Month, aDT.Year );
double fSerial = static_cast<double>(GetDayDiff( aDate ));
double fSerial = aDate.IsEmpty() ? 0 : static_cast<double>(GetDayDiff( aDate ));
long nSeconds = aTime.GetHour();
nSeconds *= 3600;
nSeconds += aTime.GetMin() * 60;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment