php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53717 checking the number of arguments is wrong in zend_parse_method_parameters_ex()
Submitted: 2011-01-12 10:05 UTC Modified: 2011-01-12 23:18 UTC
From: klaus at triendl dot eu Assigned: felipe (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: klaus at triendl dot eu
New email:
PHP Version: OS:

 

 [2011-01-12 10:05 UTC] klaus at triendl dot eu
Description:
------------
Starting with PHP 5.3.0, zend_parse_method_parameters() and zend_parse_method_parameters_ex() check the number of passed arguments not to be 0.
However, zend_parse_method_parameters_ex() passes num_args-1 to RETURN_IF_ZERO_ARGS, yielding immediate function return with return code FAILURE - checking the passed arguments fails incorrectly.

See the 'test script' code for an idea how the problem scenario looks like.
Note: the code for the 'test script' isn't php script code but rather C++ code for a class exposed from a custom php extension.

Test script:
---------------
/* {{{ proto void MySample::__destruct() */
ZEND_METHOD(mysample_class, __destruct)
{
	zval* objid;
#if 1	// fails: zend_parse_method_parameters_ex() returns FAILURE
	if (zend_parse_method_parameters_ex(0, ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &objid, mysample_class_entry) == FAILURE)
		return;
#else	// ... whereas zend_parse_method_parameters() returns SUCCESS
	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &objid, mysample_class_entry) == FAILURE)
		return;
#endif

	mysample_class* pobj = (mysample_class*) zend_object_store_get_object(objid TSRMLS_CC);
	
	// ...
}
/* }}} */


Expected result:
----------------
zend_parse_method_parameters_ex() should return SUCCESS just as zend_parse_method_parameters() does

Actual result:
--------------
zend_parse_method_parameters_ex() returns FAILURE

Patches

zend_API.c.diff (last revision 2011-01-12 09:06 UTC by klaus at triendl dot eu)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-12 23:17 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=307424
Log: - Fixed bug #53717 (checking the number of arguments is wrong in zend_parse_method_parameters_ex())
  patch by: klaus at triendl dot eu
 [2011-01-12 23:18 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
 [2011-01-12 23:18 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 16:01:37 2025 UTC