View Issue Details

IDProjectCategoryView StatusLast Update
0029812FPCFCLpublic2016-03-16 18:52
Reportersilvioprog Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Target Version3.0.2Fixed in Version3.1.1 
Summary0029812: [PATCH] Avoid AVs in possible unsafe cast
DescriptionHello,

The patch in attachment avoid AVs in possible unsafe cast. (by Gilson Nunes)
TagsNo tags attached.
Fixed in Revision33215
FPCOldBugId
FPCTarget
Attached Files

Activities

silvioprog

2016-03-11 03:31

reporter  

0001-fcl-pdf-avoid-AVs-in-possible-unsafe-cast.-patch-fro.patch (1,089 bytes)   
From feeeb212f07c7e19554067fe5e8aa00d3f58e8ae Mon Sep 17 00:00:00 2001
From: silvioprog <silvioprog@gmail.com>
Date: Thu, 10 Mar 2016 23:21:56 -0300
Subject: [PATCH 1/1] fcl-pdf: avoid AVs in possible unsafe cast. (patch from
 Gilson Nunes)

---
 packages/fcl-pdf/src/fppdf.pp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/packages/fcl-pdf/src/fppdf.pp b/packages/fcl-pdf/src/fppdf.pp
index c288742..9b7ec05 100644
--- a/packages/fcl-pdf/src/fppdf.pp
+++ b/packages/fcl-pdf/src/fppdf.pp
@@ -2713,10 +2713,15 @@ end;
 function TPDFDocument.IndexOfGlobalXRef(const AValue: string): integer;
 var
   i: integer;
+  p : TPDFObject;
 begin
-  for i:=1 to Pred(FGlobalXRefs.Count) do
-    if TPDFName(GetX(i).Dict.Elements[0].Value).Name=AValue then
-      Result:=i;
+  for i := 1 to Pred(FGlobalXRefs.Count) do
+  begin
+    p := GetX(i).Dict.Elements[0].Value;
+    if p is TPDFName then
+      if TPDFName(p).Name = AValue then
+        Result := i;
+  end;
 end;
 
 function TPDFDocument.FindGlobalXRef(const AName: String): TPDFXRef;
-- 
1.9.5.msysgit.0

Michael Van Canneyt

2016-03-11 08:37

administrator   ~0090875

Patched, and improved to exit loop early when match is found.
Thanks for the contribution.

Vincent Snijders

2016-03-12 13:41

manager   ~0090931

Improved loop logic: Does that include the fact that
p:=GetX(i).Dict.Elements[0].Value is accessed now for i=0, while before it was accessed for i>=1?

Michael Van Canneyt

2016-03-12 21:56

administrator   ~0090951

Yes. The list starts at index 0.

Michael Van Canneyt

2016-03-15 08:42

administrator   ~0091053

Seems I was wrong in my assertion that the 0-th element can be used. Fixed in 33255.

silvioprog

2016-03-16 18:52

reporter   ~0091129

Thank you! (y)

Issue History

Date Modified Username Field Change
2016-03-11 03:31 silvioprog New Issue
2016-03-11 03:31 silvioprog File Added: 0001-fcl-pdf-avoid-AVs-in-possible-unsafe-cast.-patch-fro.patch
2016-03-11 08:37 Michael Van Canneyt Fixed in Revision => 33215
2016-03-11 08:37 Michael Van Canneyt Note Added: 0090875
2016-03-11 08:37 Michael Van Canneyt Status new => resolved
2016-03-11 08:37 Michael Van Canneyt Fixed in Version => 3.1.1
2016-03-11 08:37 Michael Van Canneyt Resolution open => fixed
2016-03-11 08:37 Michael Van Canneyt Assigned To => Michael Van Canneyt
2016-03-11 08:37 Michael Van Canneyt Target Version => 3.0.2
2016-03-12 13:41 Vincent Snijders Note Added: 0090931
2016-03-12 21:56 Michael Van Canneyt Note Added: 0090951
2016-03-15 08:42 Michael Van Canneyt Note Added: 0091053
2016-03-16 18:52 silvioprog Note Added: 0091129
2016-03-16 18:52 silvioprog Status resolved => closed