diff options
author | Dmitry Shulga <Dmitry.Shulga@oracle.com> | 2011-02-04 10:59:55 +0600 |
---|---|---|
committer | Dmitry Shulga <Dmitry.Shulga@oracle.com> | 2011-02-04 10:59:55 +0600 |
commit | 4e9e30434e46bb81ed87f2b64652e7431517d1ff (patch) | |
tree | 9bc91995139c6a33bb08ddac3d496724cd5394a7 /regex/regcomp.c | |
parent | 9abc2aadc55cc55f71bd6e348dc44e875c8cfbf8 (diff) | |
parent | 378091e434d66dcc7081f991a07db2244dbb8cda (diff) | |
download | mariadb-git-4e9e30434e46bb81ed87f2b64652e7431517d1ff.tar.gz |
Merge from mysql-5.1 for bug#58026.
Diffstat (limited to 'regex/regcomp.c')
-rw-r--r-- | regex/regcomp.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/regex/regcomp.c b/regex/regcomp.c index b41a1ae6da9..6e2d2511fc1 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -31,6 +31,9 @@ struct parse { CHARSET_INFO *charset; /* for ctype things */ }; +/* Check if there is enough stack space for recursion. */ +my_regex_stack_check_t my_regex_enough_mem_in_stack= NULL; + #include "regcomp.ih" static char nuls[10]; /* place to point scanner in event of error */ @@ -117,7 +120,7 @@ CHARSET_INFO *charset; # define GOODFLAGS(f) ((f)&~REG_DUMP) #endif - my_regex_init(charset); /* Init cclass if neaded */ + my_regex_init(charset, NULL); /* Init cclass if neaded */ preg->charset=charset; cflags = GOODFLAGS(cflags); if ((cflags®_EXTENDED) && (cflags®_NOSPEC)) @@ -222,7 +225,15 @@ int stop; /* character this ERE should end at */ /* do a bunch of concatenated expressions */ conc = HERE(); while (MORE() && (c = PEEK()) != '|' && c != stop) - p_ere_exp(p); + { + if (my_regex_enough_mem_in_stack && + my_regex_enough_mem_in_stack()) + { + SETERROR(REG_ESPACE); + return; + } + p_ere_exp(p); + } if(REQUIRE(HERE() != conc, REG_EMPTY)) {}/* require nonempty */ if (!EAT('|')) |