cvs: php4(PHP_4_3) /main streams.c
| From: | Sascha Schumann | Date: | Wed, 16 Apr 2003 12:55:21 +0000 |
| Subject: | cvs: php4(PHP_4_3) /main streams.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20315@lists.php.net to get a copy of this message | ||
sas Wed Apr 16 08:55:21 2003 EDT
Modified files: (Branch: PHP_4_3)
/php4/main streams.c
Log:
Accessing "stream" after freeing it is not a good idea
==32692== Invalid read of size 4
==32692== at 0x80CAFB3: _php_stream_free (/home/sas/src/php4/main/streams.c:395)
==32692== by 0x80CE096: _php_stream_cast (/home/sas/src/php4/main/streams.c:2244)
==32692== by 0x80CEDD4: _php_stream_open_wrapper_as_file
(/home/sas/src/php4/main/streams.c:2684)
==32692== by 0x80C1C6E: php_fopen_wrapper_for_zend (/home/sas/src/php4/main/main.c:761)
==32692== Address 0x414487EC is 44 bytes inside a block of size 116 free'd
==32692== at 0x401622FB: free (vg_clientfuncs.c:182)
==32692== by 0x80DB337: _efree (/home/sas/src/php4/Zend/zend_alloc.c:265)
==32692== by 0x80CAFAF: _php_stream_free (/home/sas/src/php4/main/streams.c:393)
==32692== by 0x80CE096: _php_stream_cast (/home/sas/src/php4/main/streams.c:2244)
Index: php4/main/streams.c
diff -u php4/main/streams.c:1.125.2.51 php4/main/streams.c:1.125.2.52
--- php4/main/streams.c:1.125.2.51 Mon Apr 14 21:30:59 2003
+++ php4/main/streams.c Wed Apr 16 08:55:21 2003
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.125.2.51 2003/04/15 01:30:59 iliaa Exp $ */
+/* $Id: streams.c,v 1.125.2.52 2003/04/16 12:55:21 sas Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -363,6 +363,11 @@
stream->readbuf = NULL;
}
+ if (stream->is_persistent) {
+ /* we don't work with *stream but need its value for comparison */
+ zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t)
_php_stream_free_persistent, stream TSRMLS_CC);
+ }
+
#if ZEND_DEBUG
if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) && (stream->__exposed == 0)
&& (EG(error_reporting) & E_WARNING)) {
/* it leaked: Lets deliberately NOT pefree it so that the memory manager shows it
@@ -392,10 +397,6 @@
#else
pefree(stream, stream->is_persistent);
#endif
- if (stream->is_persistent) {
- /* we don't work with *stream but need its value for comparison */
- zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t)
_php_stream_free_persistent, stream TSRMLS_CC);
- }
}
return ret;