changeset 27367:fd9caca28fcc

Improve error message if invalid UTF-8 is passed to pcre (bug #56805). * lo-regexp.cc (regexp::match): Improve error message if invalid UTF-8 is passed to pcre.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 03 Sep 2019 20:44:48 +0200
parents 4fef3ab19046
children 71d9bd3332e4
files liboctave/util/lo-regexp.cc
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/lo-regexp.cc	Tue Sep 03 19:56:08 2019 +0200
+++ b/liboctave/util/lo-regexp.cc	Tue Sep 03 20:44:48 2019 +0200
@@ -312,7 +312,11 @@
               }
           }
 
-        if (matches < 0 && matches != PCRE_ERROR_NOMATCH)
+        if (matches == PCRE_ERROR_BADUTF8)
+          (*current_liboctave_error_handler)
+            ("%s: internal error calling pcre_exec; "
+             "the input string is invalid UTF-8", who.c_str ());
+        else if (matches < 0 && matches != PCRE_ERROR_NOMATCH)
           (*current_liboctave_error_handler)
             ("%s: internal error calling pcre_exec; "
              "error code from pcre_exec is %i", who.c_str (), matches);