- typo
[m6w6/ext-http] / http_url_api.c
index 83d295af4f58e92eb37c811fffcd6095c171c9a5..b32fd9d454758e44191b05bf2114213e51406c7c 100644 (file)
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
 #endif
-
 #include "php.h"
+
+#include "SAPI.h"
 #include "zend_ini.h"
 #include "php_output.h"
 #include "ext/standard/url.h"
 
-#include "SAPI.h"
-
-#include "phpstr/phpstr.h"
-
 #include "php_http.h"
 #include "php_http_api.h"
 #include "php_http_url_api.h"
 #include "php_http_std_defs.h"
 
+#include "phpstr/phpstr.h"
+
 #ifdef PHP_WIN32
 #      include <winsock2.h>
 #elif defined(HAVE_NETDB_H)
@@ -54,7 +53,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 +62,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 +123,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 +173,7 @@ PHP_HTTP_API char *_http_absolute_url_ex(
                efree(scheme);
        }
        php_url_free(purl);
+       efree(uri);
 
        return URL;
 }