]> granicus.if.org Git - php/commitdiff
Fix leak, and avoid initialization problems where retval is re-used
authorWez Furlong <wez@php.net>
Tue, 15 Oct 2002 01:57:19 +0000 (01:57 +0000)
committerWez Furlong <wez@php.net>
Tue, 15 Oct 2002 01:57:19 +0000 (01:57 +0000)
within a function.

main/user_streams.c

index 9ee823f3dfc6af920684eaa97ed5162451fb597c..ac0461320d0a4cef2b0bd6036e99c30d6051bcd5 100644 (file)
@@ -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;
 }