X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_url_api.c;h=288abe445b1f88067777a33fa3dc90101923f2c1;hp=83d295af4f58e92eb37c811fffcd6095c171c9a5;hb=77b24e0e5f85b64a168a4ea4ce83db9339b1f31b;hpb=2acce3eb2d1815e2882608da632c3fd5614b389c diff --git a/http_url_api.c b/http_url_api.c index 83d295a..288abe4 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -54,7 +54,7 @@ PHP_HTTP_API char *_http_absolute_url_ex( php_url *purl, furl = {NULL}; size_t full_len = 0; zval *zhost = NULL; - char *scheme = NULL, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1); + char *scheme = NULL, *uri, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1); if ((!url || !url_len) && ( (!(url = SG(request_info).request_uri)) || @@ -63,7 +63,8 @@ PHP_HTTP_API char *_http_absolute_url_ex( return NULL; } - if (!(purl = php_url_parse((char *) url))) { + uri = estrndup(url, url_len); + if (!(purl = php_url_parse(uri))) { http_error_ex(E_WARNING, HTTP_E_PARSE, "Could not parse supplied URL: %s", url); return NULL; } @@ -123,6 +124,7 @@ PHP_HTTP_API char *_http_absolute_url_ex( efree(scheme); \ } \ php_url_free(purl); \ + efree(uri); \ return URL; \ } else { \ strcat(URL, add_string); \ @@ -172,6 +174,7 @@ PHP_HTTP_API char *_http_absolute_url_ex( efree(scheme); } php_url_free(purl); + efree(uri); return URL; }