From be4b75b136585ce13beced592641e7686fa4a742 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Tue, 13 Feb 2007 19:50:13 +0000 Subject: [PATCH] improve php_userstreamop_seek() check for errors in stream_seek() and return correct status --- main/streams/userspace.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/main/streams/userspace.c b/main/streams/userspace.c index a5b1d79fd5b..3c68b5d20b3 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -759,6 +759,10 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o retval = NULL; } + if (ret) { + return ret; + } + /* now determine where we are */ ZVAL_STRINGL(&func_name, USERSTREAM_TELL, sizeof(USERSTREAM_TELL)-1, 0); @@ -768,16 +772,20 @@ static int php_userstreamop_seek(php_stream *stream, off_t offset, int whence, o &retval, 0, NULL, 0, NULL TSRMLS_CC); - if (call_result == SUCCESS && retval != NULL && Z_TYPE_P(retval) == IS_LONG) + if (call_result == SUCCESS && retval != NULL && Z_TYPE_P(retval) == IS_LONG) { *newoffs = Z_LVAL_P(retval); - else - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!", - us->wrapper->classname); + ret = 0; + } else if (call_result == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!", us->wrapper->classname); + ret = -1; + } else { + ret = -1; + } - if (retval) + if (retval) { zval_ptr_dtor(&retval); - - return 0; + } + return ret; } /* parse the return value from one of the stat functions and store the