diff -ur pcre-8.31.orig/pcre_compile.c pcre-8.31/pcre_compile.c
--- pcre-8.31.orig/pcre_compile.c	2012-06-20 21:08:50.000000000 +0600
+++ pcre-8.31/pcre_compile.c	2014-07-03 17:18:04.314881746 +0600
@@ -1292,11 +1292,15 @@
 /* Read the minimum value and do a paranoid check: a negative value indicates
 an integer overflow. */
 
-while (IS_DIGIT(*p)) min = min * 10 + *p++ - CHAR_0;
-if (min < 0 || min > 65535)
+while (IS_DIGIT(*p))
   {
-  *errorcodeptr = ERR5;
-  return p;
+  min = min * 10 + (int)(*p++ - CHAR_0);
+  if (min > 65535)
+    {
+    *errorcodeptr = ERR5;
+    while (*p != CHAR_RIGHT_CURLY_BRACKET) p++;
+    return p;
+    }
   }
 
 /* Read the maximum value if there is one, and again do a paranoid on its size.
@@ -1307,11 +1311,15 @@
   if (*(++p) != CHAR_RIGHT_CURLY_BRACKET)
     {
     max = 0;
-    while(IS_DIGIT(*p)) max = max * 10 + *p++ - CHAR_0;
-    if (max < 0 || max > 65535)
+    while(IS_DIGIT(*p))
       {
-      *errorcodeptr = ERR5;
-      return p;
+      max = max * 10 + (int)(*p++ - CHAR_0);
+      if (max > 65535)
+        {
+        *errorcodeptr = ERR5;
+        while (*p != CHAR_RIGHT_CURLY_BRACKET) p++;
+        return p;
+        }
       }
     if (max < min)
       {
