From: Michael Wallner Date: Mon, 17 Jul 2006 09:28:44 +0000 (+0000) Subject: - fix overload guards leaks X-Git-Tag: RELEASE_1_1_0~2 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=c8dff7011092296f9fcc12e68ad8eef18b19cdf4 - fix overload guards leaks --- diff --git a/KnownIssues.txt b/KnownIssues.txt index ea870ec..19c593c 100644 --- a/KnownIssues.txt +++ b/KnownIssues.txt @@ -18,5 +18,5 @@ not check for zlib header bytes. This is not preventable AFAICS. not work as expected in a PHP version lower than 5.1.3. Internals: - - our http_urlencode_hash() only handles arrays and does not - differentiate between prefixes for numeric or string keys. + - our http_urlencode_hash() does not differentiate between prefixes + for numeric or string keys. diff --git a/http.c b/http.c index 348940b..874528e 100644 --- a/http.c +++ b/http.c @@ -107,9 +107,7 @@ zend_function_entry http_functions[] = { PHP_FE(http_put_file, http_arg_pass_ref_4) PHP_FE(http_put_stream, http_arg_pass_ref_4) PHP_FE(http_request, http_arg_pass_ref_5) -#ifdef HAVE_CURL_GETFORMDATA PHP_FE(http_request_body_encode, NULL) -#endif #endif PHP_FE(http_request_method_register, NULL) PHP_FE(http_request_method_unregister, NULL) diff --git a/http_deflatestream_object.c b/http_deflatestream_object.c index 161578f..b535cf5 100644 --- a/http_deflatestream_object.c +++ b/http_deflatestream_object.c @@ -126,14 +126,10 @@ void _http_deflatestream_object_free(zend_object *object TSRMLS_DC) { http_deflatestream_object *o = (http_deflatestream_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } if (o->stream) { http_encoding_deflate_stream_free(&o->stream); } - efree(o); + freeObject(o); } /* {{{ proto void HttpDeflateStream::__construct([int flags = 0]) diff --git a/http_inflatestream_object.c b/http_inflatestream_object.c index 851980e..ef687d4 100644 --- a/http_inflatestream_object.c +++ b/http_inflatestream_object.c @@ -115,14 +115,10 @@ void _http_inflatestream_object_free(zend_object *object TSRMLS_DC) { http_inflatestream_object *o = (http_inflatestream_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } if (o->stream) { http_encoding_inflate_stream_free(&o->stream); } - efree(o); + freeObject(o); } /* {{{ proto void HttpInflateStream::__construct([int flags = 0]) diff --git a/http_message_object.c b/http_message_object.c index eb35995..1a5980e 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -368,10 +368,6 @@ void _http_message_object_free(zend_object *object TSRMLS_DC) { http_message_object *o = (http_message_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } if (o->message) { http_message_dtor(o->message); efree(o->message); @@ -384,7 +380,7 @@ void _http_message_object_free(zend_object *object TSRMLS_DC) p.value.obj = o->parent; zend_objects_store_del_ref(&p TSRMLS_CC); } - efree(o); + freeObject(o); } static zval *_http_message_object_read_prop(zval *object, zval *member, int type TSRMLS_DC) diff --git a/http_querystring_object.c b/http_querystring_object.c index d8de9e1..d629df0 100644 --- a/http_querystring_object.c +++ b/http_querystring_object.c @@ -198,11 +198,7 @@ void _http_querystring_object_free(zend_object *object TSRMLS_DC) { http_querystring_object *o = (http_querystring_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } - efree(o); + freeObject(o); } /* {{{ querystring helpers */ diff --git a/http_request_object.c b/http_request_object.c index 7b15faa..fc039f8 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -471,12 +471,8 @@ void _http_request_object_free(zend_object *object TSRMLS_DC) { http_request_object *o = (http_request_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } http_request_free(&o->request); - efree(o); + freeObject(o); } #define http_request_object_check_request_content_type(t) _http_request_object_check_request_content_type((t) TSRMLS_CC) diff --git a/http_requestpool_object.c b/http_requestpool_object.c index ddef318..6ae9cd9 100644 --- a/http_requestpool_object.c +++ b/http_requestpool_object.c @@ -134,12 +134,8 @@ void _http_requestpool_object_free(zend_object *object TSRMLS_DC) { http_requestpool_object *o = (http_requestpool_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } http_request_pool_dtor(&o->pool); - efree(o); + freeObject(o); } #define http_requestpool_object_llist2array _http_requestpool_object_llist2array diff --git a/php_http.h b/php_http.h index 86c8eca..3f11b66 100644 --- a/php_http.h +++ b/php_http.h @@ -26,14 +26,13 @@ #endif #include "php.h" +#include "missing.h" #include "php_http_std_defs.h" #include "phpstr/phpstr.h" -#include "missing.h" #ifdef HTTP_WANT_SAPI # if PHP_API_VERSION > 20041225 # define HTTP_HAVE_SAPI_RTIME -# else # endif # include "SAPI.h" #endif @@ -198,9 +197,7 @@ PHP_FUNCTION(http_put_data); PHP_FUNCTION(http_put_file); PHP_FUNCTION(http_put_stream); PHP_FUNCTION(http_request); -#ifdef HAVE_CURL_GETFORMDATA PHP_FUNCTION(http_request_body_encode); -#endif /* HAVE_CURL_GETFORMDATA */ #endif /* HTTP_HAVE_CURL */ PHP_FUNCTION(http_request_method_register); PHP_FUNCTION(http_request_method_unregister); diff --git a/php_http_std_defs.h b/php_http_std_defs.h index b4218bd..2f92c87 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -246,7 +246,27 @@ typedef int STATUS; # define getObject(t, o) getObjectEx(t, o, getThis()) # define getObjectEx(t, o, v) t * o = ((t *) zend_object_store_get_object(v TSRMLS_CC)) # define putObject(t, o) zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) _ ##t## _free, NULL TSRMLS_CC); +# ifndef WONKY +# define freeObject(o) \ + if (OBJ_GUARDS(o)) { \ + zend_hash_destroy(OBJ_GUARDS(o)); \ + FREE_HASHTABLE(OBJ_GUARDS(o)); \ + } \ + if (OBJ_PROP(o)) { \ + zend_hash_destroy(OBJ_PROP(o)); \ + FREE_HASHTABLE(OBJ_PROP(o)); \ + } \ + efree(o); +# else +# define freeObject(o) \ + if (OBJ_PROP(o)) { \ + zend_hash_destroy(OBJ_PROP(o)); \ + FREE_HASHTABLE(OBJ_PROP(o)); \ + } \ + efree(o); +# endif # define OBJ_PROP(o) (o)->zo.properties +# define OBJ_GUARDS(o) (o)->zo.guards # define DCL_STATIC_PROP(a, t, n, v) zend_declare_property_ ##t(OBJ_PROP_CE, (#n), sizeof(#n)-1, (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC) # define DCL_STATIC_PROP_Z(a, n, v) zend_declare_property(OBJ_PROP_CE, (#n), sizeof(#n)-1, (v), (ZEND_ACC_ ##a | ZEND_ACC_STATIC) TSRMLS_CC)