summaryrefslogtreecommitdiff
path: root/main/user_streams.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-10-15 01:57:19 +0000
committerWez Furlong <wez@php.net>2002-10-15 01:57:19 +0000
commit6890f98e708e40e54d0bd0e589e3b5e39c5ca191 (patch)
tree15c5a48c6b1f5dbc8a684ffc260fe8d9534f3c93 /main/user_streams.c
parente737d2c06921084af43ea7206ceb5dced03342c5 (diff)
downloadphp-git-6890f98e708e40e54d0bd0e589e3b5e39c5ca191.tar.gz
Fix leak, and avoid initialization problems where retval is re-used
within a function.
Diffstat (limited to 'main/user_streams.c')
-rw-r--r--main/user_streams.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/main/user_streams.c b/main/user_streams.c
index 9ee823f3df..ac0461320d 100644
--- a/main/user_streams.c
+++ b/main/user_streams.c
@@ -464,8 +464,10 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
}
zval_ptr_dtor(&zcount);
- if (retval)
+ if (retval) {
zval_ptr_dtor(&retval);
+ retval = NULL;
+ }
/* since the user stream has no way of setting the eof flag directly, we need to ask it if we hit eof */
@@ -487,6 +489,11 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
stream->eof = 1;
}
+ if (retval) {
+ zval_ptr_dtor(&retval);
+ retval = NULL;
+ }
+
return didread;
}
@@ -586,8 +593,10 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o
ret = -1;
}
- if (retval)
+ if (retval) {
zval_ptr_dtor(&retval);
+ retval = NULL;
+ }
/* now determine where we are */
ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1, 0);
@@ -603,10 +612,10 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o
else
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!",
us->wrapper->classname);
-
+
if (retval)
zval_ptr_dtor(&retval);
-
+
return 0;
}