Avoid core dump on symcomp("").
diff --git a/Modules/regexmodule.c b/Modules/regexmodule.c
index 893f4fc..33801af 100644
--- a/Modules/regexmodule.c
+++ b/Modules/regexmodule.c
@@ -398,6 +398,11 @@
object *npattern;
int require_escape = re_syntax & RE_NO_BK_PARENS ? 0 : 1;
+ if (oend == opat) {
+ INCREF(pattern);
+ return pattern;
+ }
+
npattern = newsizedstringobject((char*)NULL, getstringsize(pattern));
if (npattern == NULL)
return NULL;
@@ -466,7 +471,6 @@
if (resizestring(&npattern, n - getstringvalue(npattern)) == 0)
return npattern;
else {
- DECREF(npattern);
return NULL;
}