[Pcre-svn] [1148] code/trunk: Refactor the solution of the u…

Startseite
Nachricht löschen
Autor: Subversion repository
Datum:  
To: pcre-svn
Betreff: [Pcre-svn] [1148] code/trunk: Refactor the solution of the unsigned overflow.
Revision: 1148
          http://vcs.pcre.org/viewvc?view=rev&revision=1148
Author:   zherczeg
Date:     2012-10-20 21:52:52 +0100 (Sat, 20 Oct 2012)


Log Message:
-----------
Refactor the solution of the unsigned overflow.

Modified Paths:
--------------
    code/trunk/pcre_compile.c
    code/trunk/pcre_study.c


Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2012-10-20 20:17:03 UTC (rev 1147)
+++ code/trunk/pcre_compile.c    2012-10-20 20:52:52 UTC (rev 1148)
@@ -1914,26 +1914,20 @@


     /* Check a class for variable quantification */


-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-    case OP_XCLASS:
-#endif
     case OP_CLASS:
     case OP_NCLASS:
-
-    switch (op)
-      {
 #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-      case OP_XCLASS:
+    case OP_XCLASS:
+    /* The original code caused an unsigned overflow in 64 bit systems,
+    so now we use a conditional statement. */
+    if (op == OP_XCLASS)
       cc += GET(cc, 1);
-      break;
+    else
+      cc += PRIV(OP_lengths)[OP_CLASS];
+#else
+    cc += PRIV(OP_lengths)[OP_CLASS];
 #endif


-      case OP_CLASS:
-      case OP_NCLASS:
-      cc += PRIV(OP_lengths)[OP_CLASS];
-      break;
-      }
-
     switch (*cc)
       {
       case OP_CRPLUS:


Modified: code/trunk/pcre_study.c
===================================================================
--- code/trunk/pcre_study.c    2012-10-20 20:17:03 UTC (rev 1147)
+++ code/trunk/pcre_study.c    2012-10-20 20:52:52 UTC (rev 1148)
@@ -323,16 +323,19 @@


     /* Check a class for variable quantification */


-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
-    case OP_XCLASS:
-    cc += GET(cc, 1);
-    cc -= PRIV(OP_lengths)[OP_CLASS];
-    /* Fall through */
-#endif
-
     case OP_CLASS:
     case OP_NCLASS:
+#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
+    case OP_XCLASS:
+    /* The original code caused an unsigned overflow in 64 bit systems,
+    so now we use a conditional statement. */
+    if (op == OP_XCLASS)
+      cc += GET(cc, 1);
+    else
+      cc += PRIV(OP_lengths)[OP_CLASS];
+#else
     cc += PRIV(OP_lengths)[OP_CLASS];
+#endif


     switch (*cc)
       {