]> granicus.if.org Git - php/commitdiff
Plug the last (hopefully) of the PHP4 context leaks. This one regarding notifier...
authorSara Golemon <pollita@php.net>
Fri, 27 Jun 2003 16:16:46 +0000 (16:16 +0000)
committerSara Golemon <pollita@php.net>
Fri, 27 Jun 2003 16:16:46 +0000 (16:16 +0000)
ext/standard/file.c
main/php_streams.h
main/streams.c

index 232008ffcce277d3658ac1e0f0122039584acaef..82c9c8b2f48aaa8815c44c13b6ef6690fe8d8bd7 100644 (file)
@@ -875,6 +875,14 @@ static void user_space_stream_notifier(php_stream_context *context, int notifyco
                zval_ptr_dtor(&retval);
 }
 
+static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
+{
+       if (notifier && notifier->ptr) {
+               zval_ptr_dtor((zval **)&(notifier->ptr));
+               notifier->ptr = NULL;
+       }
+}
+
 static int parse_context_options(php_stream_context *context, zval *options)
 {
        HashPosition pos, opos;
@@ -923,6 +931,7 @@ static int parse_context_params(php_stream_context *context, zval *params)
                context->notifier->func = user_space_stream_notifier;
                context->notifier->ptr = *tmp;
                ZVAL_ADDREF(*tmp);
+               context->notifier->dtor = user_space_stream_notifier_dtor;
        }
        if ((ret = zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) == SUCCESS) {
                parse_context_options(context, *tmp);
index 83e8c8b71c03a6d11e4fdea1fd16915be48e78fc..ef65f592fea29c3f55014ab9f6e07b3e0b9db541 100755 (executable)
@@ -96,6 +96,7 @@ typedef struct _php_stream php_stream;
 typedef struct _php_stream_wrapper php_stream_wrapper;
 typedef struct _php_stream_context php_stream_context;
 typedef struct _php_stream_filter php_stream_filter;
+typedef struct _php_stream_notifier php_stream_notifier;
 
 /* callback for status notifications */
 typedef void (*php_stream_notification_func)(php_stream_context *context,
@@ -119,12 +120,13 @@ typedef struct _php_stream_dirent {
 
 #define PHP_STREAM_NOTIFIER_PROGRESS   1
 
-typedef struct _php_stream_notifier {
+struct _php_stream_notifier {
        php_stream_notification_func func;
+       void (*dtor)(php_stream_notifier *notifier);
        void *ptr;
        int mask;
        size_t progress, progress_max; /* position for progress notification */
-} php_stream_notifier;
+};
 
 struct _php_stream_context {
        php_stream_notifier *notifier;
index 8ea9f18a872e5f3d2e9b604af2657dae81143193..a549b5924719b7115a7422f429ca827417c86be4 100755 (executable)
@@ -2849,6 +2849,9 @@ PHPAPI php_stream_notifier *php_stream_notification_alloc(void)
 
 PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
 {
+       if (notifier->dtor) {
+               notifier->dtor(notifier);
+       }
        efree(notifier);
 }