From 6e259b76b754f100b7a0354a8f92088c493ecd80 Mon Sep 17 00:00:00 2001
From: Witchakorn Kamolpornwijit <witchakk@mit.edu>
Date: Sat, 1 Nov 2014 21:01:56 -0400
Subject: [PATCH] Fix range check in map_html_tags()

---
 src/ChangeLog    | 4 ++++
 src/html-parse.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 19b49610..435026e3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-12  Witchakorn Kamolpornwijit <witchakk@mit.edu> (tiny change)
+
+	* html-parse.c (map_html_tags): Fix range check
+
 2014-11-11  Tim Ruehsen  <tim.ruehsen@gmx.de>
  
 	* openssl.c (ssl_init): Load CRL file given by --crl-file
diff --git a/src/html-parse.c b/src/html-parse.c
index f9418c70..b7a90dac 100644
--- a/src/html-parse.c
+++ b/src/html-parse.c
@@ -881,7 +881,7 @@ map_html_tags (const char *text, int size,
     if (*p == '!')
       {
         if (!(flags & MHT_STRICT_COMMENTS)
-            && p < end + 3 && p[1] == '-' && p[2] == '-')
+            && p + 3 < end && p[1] == '-' && p[2] == '-')
           {
             /* If strict comments are not enforced and if we know
                we're looking at a comment, simply look for the