Pārlūkot izejas kodu

* Applied patch from Mattias Gaertner, fixing bug ID #28773

git-svn-id: trunk@31942 -
michael 9 gadi atpakaļ
vecāks
revīzija
94ff51c67e
1 mainītis faili ar 12 papildinājumiem un 3 dzēšanām
  1. 12 3
      packages/fcl-image/src/fpreadtiff.pas

+ 12 - 3
packages/fcl-image/src/fpreadtiff.pas

@@ -1486,11 +1486,20 @@ begin
   if EntryType<>2 then
     TiffError('asciiz expected, but found '+IntToStr(EntryType));
   EntryCount:=ReadDWord;
-  EntryStart:=ReadDWord;
-  SetStreamPos(EntryStart);
   SetLength(Result,EntryCount-1);
-  if EntryCount>1 then
+  if EntryCount>4 then begin
+    // long string -> next 4 DWord is the offset
+    EntryStart:=ReadDWord;
+    SetStreamPos(EntryStart);
     s.Read(Result[1],EntryCount-1);
+  end else begin
+    // short string -> stored directly in the next 4 bytes
+    if Result<>'' then
+      s.Read(Result[1],length(Result));
+    // skip rest of 4 bytes
+    if length(Result)<4 then
+      s.Read(EntryStart,4-length(Result));
+  end;
 end;
 
 function TFPReaderTiff.ReadByte: Byte;