diff options
author | Thies C. Arntzen <thies@php.net> | 2000-02-16 11:47:20 +0000 |
---|---|---|
committer | Thies C. Arntzen <thies@php.net> | 2000-02-16 11:47:20 +0000 |
commit | 98193914426b4a115e9925f337a5ed89346543b8 (patch) | |
tree | c0a70ed9557d7fbb3e8ff4cb546c534a010b9df7 /ext/standard/url.c | |
parent | 1fae341a98e99df7eb374d7a47dea42b9c13c4e9 (diff) | |
download | php-git-98193914426b4a115e9925f337a5ed89346543b8.tar.gz |
(url_parse) only free regex if compile worked.
Diffstat (limited to 'ext/standard/url.c')
-rw-r--r-- | ext/standard/url.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/standard/url.c b/ext/standard/url.c index ededaddc8c..351399e60a 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -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 */ |