Browse Source

* Fix bug ID #33886, handle files of less than 3 bytes

git-svn-id: trunk@39324 -
michael 7 years ago
parent
commit
b0c0102db4
1 changed files with 6 additions and 2 deletions
  1. 6 2
      packages/fcl-base/src/csvreadwrite.pp

+ 6 - 2
packages/fcl-base/src/csvreadwrite.pp

@@ -459,8 +459,12 @@ begin
   FSourceStream.Seek(0, soFromBeginning);
   FSourceStream.Seek(0, soFromBeginning);
   if FDetectBOM then
   if FDetectBOM then
   begin
   begin
-    FSourceStream.ReadBuffer(b[0], 3);
-    if (b[0] = $EF) and (b[1] = $BB) and (b[2] = $BF) then begin
+    if FSourceStream.Read(b[0], 3)<3 then
+      begin
+      n:=0;
+      FBOM:=bomNone;
+      end
+    else if (b[0] = $EF) and (b[1] = $BB) and (b[2] = $BF) then begin
       FBOM := bomUTF8;
       FBOM := bomUTF8;
       n := 3;
       n := 3;
     end else
     end else