]> granicus.if.org Git - python/commitdiff
Avoid core dump on symcomp("").
authorGuido van Rossum <guido@python.org>
Tue, 11 Jun 1996 18:33:14 +0000 (18:33 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 11 Jun 1996 18:33:14 +0000 (18:33 +0000)
Modules/regexmodule.c

index 893f4fc31b4dc2c3e10ee8ed1d5cf4fa6ddd44d6..33801afa90554654d51b31d1fb11370caedf6052 100644 (file)
@@ -398,6 +398,11 @@ symcomp(pattern, gdict)
        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 @@ symcomp(pattern, gdict)
        if (resizestring(&npattern, n - getstringvalue(npattern)) == 0)
                return npattern;
        else {
-               DECREF(npattern);
                return NULL;
        }