]> granicus.if.org Git - php/commitdiff
(url_parse) only free regex if compile worked.
authorThies C. Arntzen <thies@php.net>
Wed, 16 Feb 2000 11:47:20 +0000 (11:47 +0000)
committerThies C. Arntzen <thies@php.net>
Wed, 16 Feb 2000 11:47:20 +0000 (11:47 +0000)
ext/standard/url.c

index ededaddc8cf83ad5effd8cfa2e55bd8411fe6518..351399e60a07e8a9bf8d16101f6ddedec83cd538 100644 (file)
@@ -108,13 +108,15 @@ url *url_parse(char *str)
 
        /* extract the username, pass, and port from the hostname */
        if (subs[4].rm_so != -1 && subs[4].rm_so < length) {
+
+               int cerr;
                /* extract username:pass@host:port from regex results */
                result = estrndup(str + subs[4].rm_so, subs[4].rm_eo - subs[4].rm_so);
                length = strlen(result);
 
                regfree(&re);                   /* free the old regex */
                
-               if ((err=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?", REG_EXTENDED))
+               if ((cerr=regcomp(&re, "^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?", REG_EXTENDED))
                        || (err=regexec(&re, result, 10, subs, 0))) {
                        STR_FREE(ret->scheme);
                        STR_FREE(ret->path);
@@ -123,7 +125,7 @@ url *url_parse(char *str)
                        efree(ret);
                        efree(result);
                        /*php_error(E_WARNING,"Unable to compile regex: %d\n", err);*/
-                       regfree(&re);
+                       if (!cerr) regfree(&re); 
                        return NULL;
                }
                /* now deal with all of the results */