From: Wez Furlong Date: Tue, 15 Oct 2002 01:57:19 +0000 (+0000) Subject: Fix leak, and avoid initialization problems where retval is re-used X-Git-Tag: php-4.3.0pre2~368 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6890f98e708e40e54d0bd0e589e3b5e39c5ca191;p=php Fix leak, and avoid initialization problems where retval is re-used within a function. --- 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; }