75a61b
From 60b4fe65bc9dc9b82bbadf0be2e3781be796a13d Mon Sep 17 00:00:00 2001
75a61b
From: Albert Astals Cid <aacid@kde.org>
75a61b
Date: Tue, 1 May 2018 02:46:17 +0200
75a61b
Subject: FoFiType1C::cvtGlyph: Fix infinite recursion on malformed documents
75a61b
75a61b
Bugs #104942, #103238
75a61b
---
75a61b
 fofi/FoFiType1C.cc | 7 ++++---
75a61b
 1 file changed, 4 insertions(+), 3 deletions(-)
75a61b
75a61b
diff --git a/fofi/FoFiType1C.cc b/fofi/FoFiType1C.cc
75a61b
index 03e7799..b14561f 100644
75a61b
--- a/fofi/FoFiType1C.cc
75a61b
+++ b/fofi/FoFiType1C.cc
75a61b
@@ -13,7 +13,7 @@
75a61b
 // All changes made under the Poppler project to this file are licensed
75a61b
 // under GPL version 2 or later
75a61b
 //
75a61b
-// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org>
75a61b
+// Copyright (C) 2009, 2010, 2017, 2018 Albert Astals Cid <aacid@kde.org>
75a61b
 // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
75a61b
 //
75a61b
 // To see a description of the changes please see the Changelog file that
75a61b
@@ -32,6 +32,7 @@
75a61b
 #include <math.h>
75a61b
 #include "goo/gmem.h"
75a61b
 #include "goo/gstrtod.h"
75a61b
+#include "goo/GooLikely.h"
75a61b
 #include "goo/GooString.h"
75a61b
 #include "FoFiEncodings.h"
75a61b
 #include "FoFiType1C.h"
75a61b
@@ -1361,7 +1362,7 @@ void FoFiType1C::cvtGlyph(int offset, int nBytes, GooString *charBuf,
75a61b
 	  --nOps;
75a61b
 	  ok = gTrue;
75a61b
 	  getIndexVal(subrIdx, k, &val, &ok;;
75a61b
-	  if (ok) {
75a61b
+	  if (likely(ok && val.pos != offset)) {
75a61b
 	    cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse);
75a61b
 	  }
75a61b
 	} else {
75a61b
@@ -1596,7 +1597,7 @@ void FoFiType1C::cvtGlyph(int offset, int nBytes, GooString *charBuf,
75a61b
 	  --nOps;
75a61b
 	  ok = gTrue;
75a61b
 	  getIndexVal(&gsubrIdx, k, &val, &ok;;
75a61b
-	  if (ok) {
75a61b
+	  if (likely(ok && val.pos != offset)) {
75a61b
 	    cvtGlyph(val.pos, val.len, charBuf, subrIdx, pDict, gFalse);
75a61b
 	  }
75a61b
 	} else {
75a61b
-- 
75a61b
cgit v1.1
75a61b