Browse Source

* Fix foe 29990

git-svn-id: trunk@33471 -
michael 9 years ago
parent
commit
65e901c844

+ 0 - 3
packages/fcl-image/src/fphandler.inc

@@ -239,16 +239,13 @@ end;
 
 function TFPCustomImageReader.CheckContents (Str:TStream) : boolean;
 var InRead : boolean;
-    P : Int64;
 begin
   InRead := assigned(FStream);
   if not assigned(Str) then
     raise FPImageException.Create(ErrorText[StrNoStream]);
   try
     FSTream := Str;
-    P:=Str.Position;
     result := InternalCheck (Str);
-    Str.Position:=P;
   finally
     if not InRead then
       FStream := nil;

+ 4 - 0
packages/fcl-image/src/fpimage.inc

@@ -123,7 +123,9 @@ var r : integer;
     reader : TFPCustomImageReader;
     msg : string;
     d : TIHData;
+    startPos: Int64;
 begin
+  startPos := str.Position;
   with ImageHandlers do
     try
       r := count-1;
@@ -139,6 +141,7 @@ begin
             try
               if CheckContents (str) then
                 try
+                  str.Position := startPos;
                   FStream := str;
                   FImage := self;
                   InternalRead (str, self);
@@ -149,6 +152,7 @@ begin
                 end;
             finally
               Free;
+              str.Position := startPos;
             end;
           end;
         dec (r);

+ 3 - 0
packages/fcl-image/src/fpreadjpeg.pas

@@ -453,9 +453,12 @@ end;
 function TFPReaderJPEG.InternalCheck(Str: TStream): boolean;
 var
   Buf: array[0..1] of Byte = (0, 0);
+  p: Int64;
 begin
   if Str=nil then exit(false);
+  p:=Str.Position;
   Result := (Str.Read(Buf, 2)=2) and (Buf[0]=$FF) and (Buf[1]=$D8); // byte sequence FFD8 = start of image
+  Str.Position:=p;
 end;
 
 constructor TFPReaderJPEG.Create;