* Fix foe 29990

git-svn-id: trunk@33471 -
This commit is contained in:
michael 2016-04-10 13:23:30 +00:00
parent a7346b2f9d
commit 65e901c844
3 changed files with 7 additions and 3 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;