- fix overload guards leaks
authorMichael Wallner <mike@php.net>
Mon, 17 Jul 2006 09:28:44 +0000 (09:28 +0000)
committerMichael Wallner <mike@php.net>
Mon, 17 Jul 2006 09:28:44 +0000 (09:28 +0000)
KnownIssues.txt
http.c
http_deflatestream_object.c
http_inflatestream_object.c
http_message_object.c
http_querystring_object.c
http_request_object.c
http_requestpool_object.c
php_http.h
php_http_std_defs.h

index ea870ec95f444dcb873b85f487fbcc68ab3c3c2a..19c593c28024a8b9009ea4593eaea08323fb57d7 100644 (file)
@@ -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 348940b6bad82e654832dd159ade4b6f48aef538..874528ed0221d96c0429655de979a23daea2d3e9 100644 (file)
--- 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)
index 161578ff823d521100b796081276bac6346d1eea..b535cf5aaca536575f421f7f45b486c643b78224 100644 (file)
@@ -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])
index 851980ec43a345a355d6680f962ad39d9de4166c..ef687d4eb175ab8fe739d28bf40db8aa42a68b67 100644 (file)
@@ -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])
index eb35995bed76a3d7eadcc7ba21aabbf78da06681..1a5980e18b92c690576032474b0d92debe397d7e 100644 (file)
@@ -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)
index d8de9e16bb3bdbc6d7eabf05b8aaca892c0bfa7b..d629df045f2d93628b4ef65fc547293dcd836ef1 100644 (file)
@@ -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 */
index 7b15faa42c2b7155845ee47fa158650dac602f4e..fc039f824fb1e5226cdc0ccf0da2e87681ddc9e1 100644 (file)
@@ -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)
index ddef31867fb2ee55bea053805b5dbf1c80b95d78..6ae9cd96443de98aa3e921ab3bf665d278846f07 100644 (file)
@@ -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
index 86c8ecaaceeafaeaac4cd6377e3d15d488aee68a..3f11b66b47ee94dba764de3f91c935df30d759f1 100644 (file)
 #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);
index b4218bd556c1d87eea2861ec7ab50b487214b5f5..2f92c871dbefbd8f552d8c1fec80a7ec354de293 100644 (file)
@@ -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)