- 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 ea870ec..19c593c 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 348940b..874528e 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 161578f..b535cf5 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 851980e..ef687d4 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 eb35995..1a5980e 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 d8de9e1..d629df0 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 7b15faa..fc039f8 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 ddef318..6ae9cd9 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 86c8eca..3f11b66 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 b4218bd..2f92c87 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)