fpexif: Fix bug in Nikon maker note reader, caused crash for some Nikon images.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7347 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-03-30 20:39:06 +00:00
parent cb10cac905
commit 1048d9c4b1
3 changed files with 20 additions and 11 deletions

View File

@ -49,6 +49,7 @@
<Unit2>
<Filename Value="..\..\fpemakernotesanyo.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fpeMakerNoteSanyo"/>
</Unit2>
</Units>
</ProjectOptions>
@ -62,6 +63,11 @@
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<Checks>
<RangeChecks Value="True"/>
</Checks>
</CodeGeneration>
<Linking>
<Debugging>
<UseExternalDbgSyms Value="True"/>

View File

@ -185,7 +185,7 @@ type
private
FIndex: Integer;
public
constructor Create(ATagID, AIndex: Integer; AName: String; AData: TBytes;
constructor Create(ATagID: TTagID; AIndex: Integer; AName: String; AData: TBytes;
ACount: Integer; ALkupTbl: String; AOptions: TTagOptions); reintroduce;
property Index: Integer read FIndex;
end;
@ -194,7 +194,7 @@ type
private
FIndex: Integer;
public
constructor Create(ATagID, AIndex: Integer; AName: String; AValue: Integer;
constructor Create(ATagID: TTagID; AIndex: Integer; AName: String; AValue: Integer;
ALkupTbl, AFormatStr: String; ATagType: TTagType; AOptions: TTagOptions); reintroduce;
property Index: Integer read FIndex;
end;
@ -203,7 +203,7 @@ type
private
FIndex: Integer;
public
constructor Create(ATagID, AIndex: Integer; AName: String; AValue: Double;
constructor Create(ATagID: TTagID; AIndex: Integer; AName: String; AValue: Double;
AFormatStr: String; ATagType: TTagType; AOptions: TTagOptions); reintroduce;
property Index: Integer read FIndex;
end;
@ -1436,8 +1436,8 @@ end;
//==============================================================================
// TMakerNoteTag
//==============================================================================
constructor TMakerNoteIntegerTag.Create(ATagID, AIndex: Integer; AName: String;
AValue: Integer; ALkupTbl, AFormatStr: String; ATagType: TTagType;
constructor TMakerNoteIntegerTag.Create(ATagID: TTagID; AIndex: Integer;
AName: String; AValue: Integer; ALkupTbl, AFormatStr: String; ATagType: TTagType;
AOptions: TTagOptions);
begin
if not (ATagType in [ttUInt8, ttUInt16, ttUInt32, ttSInt8, ttSInt16, ttSInt32]) then
@ -1457,8 +1457,8 @@ begin
SetInteger(0, AValue, false); // false: MakeNote tags are poorly defined -> don't crash
end;
constructor TMakerNoteFloatTag.Create(ATagID, AIndex: Integer; AName: String;
AValue: Double; AFormatStr: String; ATagType: TTagType;
constructor TMakerNoteFloatTag.Create(ATagID: TTagID; AIndex: Integer;
AName: String; AValue: Double; AFormatStr: String; ATagType: TTagType;
AOptions: TTagOptions);
begin
if not (ATagType in [ttURational, ttSRational]) then
@ -1476,8 +1476,8 @@ begin
AsFloat := AValue;
end;
constructor TMakerNoteStringTag.Create(ATagID, AIndex: Integer; AName: String;
AData: TBytes; ACount: Integer; ALkupTbl: String;
constructor TMakerNoteStringTag.Create(ATagID: TTagID; AIndex: Integer;
AName: String; AData: TBytes; ACount: Integer; ALkupTbl: String;
AOptions: TTagOptions);
begin
FIndex := AIndex;

View File

@ -491,7 +491,7 @@ begin
AClass, AReadOnly);
end;
procedure TTagDefList.AddURationalTag( ATagID: TTagID; AName: String;
procedure TTagDefList.AddURationalTag(ATagID: TTagID; AName: String;
ACount: Word = 1; ADesc: String = '';
ALkupTbl: String = ''; AFormatStr: String = ''; AClass: TTagClass = nil;
AReadOnly: Boolean = false);
@ -921,6 +921,7 @@ var
s: String;
fmtStr: TStringArray;
lkup: TStringArray;
len: Integer;
begin
Result := '';
@ -941,7 +942,9 @@ begin
for i:=0 to FCount-1 do lkup[i] := '';
end else begin
lkup := Split(FLkUpTbl, '|');
for i:=Length(lkup) to FCount-1 do lkup[i] := '';
len := Length(lkup);
if len < FCount then SetLength(lkup, FCount);
for i:=len to FCount-1 do lkup[i] := '';
end;
for i:=0 to FCount-1 do begin