2418db
From e2a8d2c149988a96fec0dc0ec38001091cd9061e Mon Sep 17 00:00:00 2001
2418db
From: Jason Crain <jason@aquaticape.us>
2418db
Date: Fri, 19 Dec 2014 01:56:45 -0600
2418db
Subject: [PATCH] Move array reallocation from visitLine to startLine
2418db
2418db
Fixes potential memory corruption from writing after end of lines
2418db
array.
2418db
2418db
https://bugs.freedesktop.org/show_bug.cgi?id=84555
2418db
---
2418db
 poppler/TextOutputDev.cc | 10 +++++-----
2418db
 1 file changed, 5 insertions(+), 5 deletions(-)
2418db
2418db
diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
2418db
index 4b7ff40..9ed955e 100644
2418db
--- a/poppler/TextOutputDev.cc
2418db
+++ b/poppler/TextOutputDev.cc
2418db
@@ -4072,6 +4072,11 @@ void TextSelectionDumper::startLine()
2418db
 
2418db
 void TextSelectionDumper::finishLine()
2418db
 {
2418db
+  if (nLines == linesSize) {
2418db
+    linesSize *= 2;
2418db
+    lines = (GooList **)grealloc(lines, linesSize * sizeof(GooList *));
2418db
+  }
2418db
+
2418db
   if (words && words->getLength() > 0)
2418db
     lines[nLines++] = words;
2418db
   else if (words)
2418db
@@ -4088,11 +4093,6 @@ void TextSelectionDumper::visitLine (TextLine *line,
2418db
 {
2418db
   TextLineFrag frag;
2418db
 
2418db
-  if (nLines == linesSize) {
2418db
-    linesSize *= 2;
2418db
-    lines = (GooList **)grealloc(lines, linesSize * sizeof(GooList *));
2418db
-  }
2418db
-
2418db
   frag.init(line, edge_begin, edge_end - edge_begin);
2418db
 
2418db
   if (tableId >= 0 && frag.line->blk->tableId < 0) {
2418db
-- 
2418db
2.1.3
2418db