pollita         Fri Jun 27 12:16:46 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/ext/standard       file.c 
    /php-src/main       php_streams.h streams.c 
  Log:
  Plug the last (hopefully) of the PHP4 context leaks.  This one regarding 
notifier->ptr
  
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.29 php-src/ext/standard/file.c:1.279.2.30
--- php-src/ext/standard/file.c:1.279.2.29      Thu Jun 26 21:46:30 2003
+++ php-src/ext/standard/file.c Fri Jun 27 12:16:46 2003
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.279.2.29 2003/06/27 01:46:30 pollita Exp $ */
+/* $Id: file.c,v 1.279.2.30 2003/06/27 16:16:46 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -875,6 +875,14 @@
                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 @@
                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: php-src/main/php_streams.h
diff -u php-src/main/php_streams.h:1.61.2.14 php-src/main/php_streams.h:1.61.2.15
--- php-src/main/php_streams.h:1.61.2.14        Fri May 30 21:37:44 2003
+++ php-src/main/php_streams.h  Fri Jun 27 12:16:46 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_streams.h,v 1.61.2.14 2003/05/31 01:37:44 sniper Exp $ */
+/* $Id: php_streams.h,v 1.61.2.15 2003/06/27 16:16:46 pollita Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -96,6 +96,7 @@
 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 @@
 
 #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: php-src/main/streams.c
diff -u php-src/main/streams.c:1.125.2.70 php-src/main/streams.c:1.125.2.71
--- php-src/main/streams.c:1.125.2.70   Thu Jun 26 23:40:55 2003
+++ php-src/main/streams.c      Fri Jun 27 12:16:46 2003
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.125.2.70 2003/06/27 03:40:55 pollita Exp $ */
+/* $Id: streams.c,v 1.125.2.71 2003/06/27 16:16:46 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -2849,6 +2849,9 @@
 
 PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
 {
+       if (notifier->dtor) {
+               notifier->dtor(notifier);
+       }
        efree(notifier);
 }
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to