[Pcre-svn] [224] code/trunk: Fix crash in pcre2test for some…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [224] code/trunk: Fix crash in pcre2test for some callouts with string arguments.
Revision: 224
          http://www.exim.org/viewvc/pcre2?view=rev&revision=224
Author:   ph10
Date:     2015-03-14 10:47:43 +0000 (Sat, 14 Mar 2015)


Log Message:
-----------
Fix crash in pcre2test for some callouts with string arguments.

Modified Paths:
--------------
    code/trunk/src/pcre2test.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testinput6
    code/trunk/testdata/testoutput2
    code/trunk/testdata/testoutput6


Modified: code/trunk/src/pcre2test.c
===================================================================
--- code/trunk/src/pcre2test.c    2015-03-12 17:00:18 UTC (rev 223)
+++ code/trunk/src/pcre2test.c    2015-03-14 10:47:43 UTC (rev 224)
@@ -4533,15 +4533,20 @@
 uint32_t i, pre_start, post_start, subject_length;
 BOOL utf = (FLD(compiled_code, overall_options) & PCRE2_UTF) != 0;
 BOOL callout_capture = (dat_datctl.control & CTL_CALLOUT_CAPTURE) != 0;
-FILE *f = (first_callout || callout_capture)? outfile : NULL;


+/* This FILE is used for echoing the subject. This is done only once in simple
+cases. */
+
+FILE *f = (first_callout || callout_capture || cb->callout_string != NULL)?
+ outfile : NULL;
+
/* For a callout with a string argument, show the string first because there
isn't a tidy way to fit it in the rest of the data. */

 if (cb->callout_string != NULL)
   {
   uint32_t delimiter = CODE_UNIT(cb->callout_string, -1); 
-  fprintf(f, "Callout: %c", delimiter);
+  fprintf(outfile, "Callout: %c", delimiter);
   PCHARSV(cb->callout_string, 0,
     cb->callout_string_length, utf, outfile);
   for (i = 0; callout_start_delims[i] != 0; i++)
@@ -4551,26 +4556,27 @@
       break;
       }  
   fprintf(outfile, "%c", delimiter);  
-  if (!callout_capture) fprintf(f, "\n");
+  if (!callout_capture) fprintf(outfile, "\n");
   } 


/* Show captured strings if required */

 if (callout_capture)
   {
-  if (cb->callout_string == NULL) fprintf(f, "Callout %d:", cb->callout_number);
-  fprintf(f, " last capture = %d\n", cb->capture_last);
+  if (cb->callout_string == NULL) 
+    fprintf(outfile, "Callout %d:", cb->callout_number);
+  fprintf(outfile, " last capture = %d\n", cb->capture_last);
   for (i = 0; i < cb->capture_top * 2; i += 2)
     {
-    fprintf(f, "%2d: ", i/2);
+    fprintf(outfile, "%2d: ", i/2);
     if (cb->offset_vector[i] == PCRE2_UNSET)
-      fprintf(f, "<unset>");
+      fprintf(outfile, "<unset>");
     else
       {
       PCHARSV(cb->subject, cb->offset_vector[i],
         cb->offset_vector[i+1] - cb->offset_vector[i], utf, f);
       }
-    fprintf(f, "\n");
+    fprintf(outfile, "\n");
     }
   }


@@ -4626,7 +4632,7 @@
pbuffer8 + cb->pattern_position);

fprintf(outfile, "\n");
-first_callout = 0;
+first_callout = FALSE;

if (cb->mark != last_callout_mark)
{

Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2015-03-12 17:00:18 UTC (rev 223)
+++ code/trunk/testdata/testinput2    2015-03-14 10:47:43 UTC (rev 224)
@@ -4218,4 +4218,10 @@
     abcdefg
     xyz123 


+/^ab(?C'first')cd(?C"second")ef/
+    abcdefg
+
+/(?:a(?C`code`)){3}X/
+    aaaXY
+
 # End of testinput2 


Modified: code/trunk/testdata/testinput6
===================================================================
--- code/trunk/testdata/testinput6    2015-03-12 17:00:18 UTC (rev 223)
+++ code/trunk/testdata/testinput6    2015-03-14 10:47:43 UTC (rev 224)
@@ -4835,4 +4835,10 @@
     abcdefg
     xyz123 


+/^ab(?C'first')cd(?C"second")ef/
+    abcdefg
+
+/(?:a(?C`code`)){3}X/
+    aaaXY
+
 # End of testinput6


Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2015-03-12 17:00:18 UTC (rev 223)
+++ code/trunk/testdata/testoutput2    2015-03-14 10:47:43 UTC (rev 224)
@@ -14146,4 +14146,27 @@
     ^          (?=abc)
  0: xyz


+/^ab(?C'first')cd(?C"second")ef/
+    abcdefg
+Callout: 'first'
+--->abcdefg
+    ^ ^         c
+Callout: "second"
+--->abcdefg
+    ^   ^       e
+ 0: abcdef
+
+/(?:a(?C`code`)){3}X/
+    aaaXY
+Callout: `code`
+--->aaaXY
+    ^^        )
+Callout: `code`
+--->aaaXY
+    ^ ^       )
+Callout: `code`
+--->aaaXY
+    ^  ^      )
+ 0: aaaX
+
 # End of testinput2 


Modified: code/trunk/testdata/testoutput6
===================================================================
--- code/trunk/testdata/testoutput6    2015-03-12 17:00:18 UTC (rev 223)
+++ code/trunk/testdata/testoutput6    2015-03-14 10:47:43 UTC (rev 224)
@@ -7887,4 +7887,27 @@
     ^          (?=abc)
  0: xyz


+/^ab(?C'first')cd(?C"second")ef/
+    abcdefg
+Callout: 'first'
+--->abcdefg
+    ^ ^         c
+Callout: "second"
+--->abcdefg
+    ^   ^       e
+ 0: abcdef
+
+/(?:a(?C`code`)){3}X/
+    aaaXY
+Callout: `code`
+--->aaaXY
+    ^^        )
+Callout: `code`
+--->aaaXY
+    ^ ^       )
+Callout: `code`
+--->aaaXY
+    ^  ^      )
+ 0: aaaX
+
 # End of testinput6