mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 20:40:40 +02:00
LCL: Take care of empty stream in TPortableAnyMapGraphic.IsStreamFormatSupported. Issue #31160, patch from José Mejuto.
git-svn-id: trunk@53867 -
This commit is contained in:
parent
c4b93b0b50
commit
a8646edc09
@ -32,16 +32,19 @@ end;
|
|||||||
class function TPortableAnyMapGraphic.IsStreamFormatSupported(Stream: TStream): Boolean;
|
class function TPortableAnyMapGraphic.IsStreamFormatSupported(Stream: TStream): Boolean;
|
||||||
var
|
var
|
||||||
Pos: Int64;
|
Pos: Int64;
|
||||||
C: Char;
|
C: array [0..1] of Char;
|
||||||
|
r: integer;
|
||||||
begin
|
begin
|
||||||
Pos := Stream.Position;
|
Pos := Stream.Position;
|
||||||
try
|
try
|
||||||
Stream.ReadBuffer(C, 1);
|
r := Stream.Read(C, 2);
|
||||||
Result := (C = 'P');
|
if r = 2 then
|
||||||
if not Result then
|
begin
|
||||||
Exit;
|
Result := (C[0] = 'P');
|
||||||
Stream.ReadBuffer(C, 1);
|
Result := Result and ((Ord(C[1])-Ord('0')) in [1..6]); // P1,P2,..,P6
|
||||||
Result := (Ord(C)-Ord('0')) in [1..6];
|
end else begin
|
||||||
|
Result := False;
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
Stream.Position := Pos;
|
Stream.Position := Pos;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user