Ver Fonte

FIX: Range check error

Alexander Koblov há 2 anos atrás
pai
commit
45046c24b7
1 ficheiros alterados com 8 adições e 4 exclusões
  1. 8 4
      components/doublecmd/dcdatetimeutils.pas

+ 8 - 4
components/doublecmd/dcdatetimeutils.pas

@@ -4,7 +4,7 @@
    Date and time functions.
 
    Copyright (C) 2009-2012 Przemysław Nagay ([email protected])
-   Copyright (C) 2017-2018 Alexander Koblov ([email protected])
+   Copyright (C) 2017-2022 Alexander Koblov ([email protected])
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -464,6 +464,7 @@ end;
 function DateTimeToUnixFileTime(DateTime : TDateTime): TUnixFileTime;
 {$IF DEFINED(UNIX)}
 var
+  AUnixTime: TTime;
   ATime: TTimeStruct;
   Year, Month, Day: Word;
   Hour, Minute, Second, MilliSecond: Word;
@@ -484,10 +485,13 @@ begin
   ATime.tm_min:= Minute;
   ATime.tm_sec:= Second;
 
-  Result:= fpMkTime(@ATime);
+  AUnixTime:= fpMkTime(@ATime);
 
-  if Result = DCBasicTypes.TFileTime(-1) then
-    raise EDateOutOfRange.Create(DateTime)
+  if (AUnixTime < 0) then
+    Result:= 0
+  else begin
+    Result:= TUnixFileTime(AUnixTime);
+  end;
 end;
 {$ELSE}
 var