Blob Blame History Raw
From 8a129c520e90fc967351f3e165f967128a88f09c Mon Sep 17 00:00:00 2001
From: Michael R Sweet <michael.r.sweet@gmail.com>
Date: Sun, 8 Dec 2019 14:00:26 -0500
Subject: [PATCH 10/10] Fix a buffer underflow issue with GCC on Linux (Issue
 #360)

---
 CHANGES.md         | 1 +
 htmldoc/ps-pdf.cxx | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/htmldoc/ps-pdf.cxx b/htmldoc/ps-pdf.cxx
index 80cf826..b931394 100644
--- a/htmldoc/ps-pdf.cxx
+++ b/htmldoc/ps-pdf.cxx
@@ -3761,7 +3761,9 @@ render_contents(tree_t *t,		/* I - Tree to parse */
          nptr < (number + sizeof(number) - 1) && width < right;
 	 width += dot_width)
       *nptr++ = '.';
-    nptr --;
+
+    if (nptr > number)
+      nptr --;
 
     strlcpy((char *)nptr, pages[hpage].page_text, sizeof(number) - (size_t)(nptr - number));
 
-- 
2.21.1