php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6552 assert_options( ASSERT_CALLBACK ) problem
Submitted: 2000-09-05 10:24 UTC Modified: 2000-09-06 09:49 UTC
From: blake at intechra dot net Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.2 OS: Linux (RedHat 6.2)
Private report: No CVE-ID: None
 [2000-09-05 10:24 UTC] blake at intechra dot net
When calling assert_options( ASSERT_CALLBACK ), the callback function is freed.  The expected behavior is that calling the function in this manner should return the name of the callback function and leave it in place.  

For example, I was doing the following:
    assert_options( ASSERT_CALLBACK, "MyACallback" );
    print( "ASSERT_CALLBACK: " . assert_options( ASSERT_CALLBACK ) . "<br>" );

The printed output is correct, but the function MyACallback is never called.  If the print line is commented out, the callback function is called with no problems.

The code in ext/standard/assert.c (starting line 299) is as follows:

	case ASSERT_CALLBACK:
		oldstr = ASSERT(callback);
		RETVAL_STRING(SAFE_STRING(oldstr),1);

		if (ac == 2) {
			convert_to_string_ex(value);
			ASSERT(callback) = estrndup((*value)->value.str.val,(*value)->value.str.len);
		}
		if (oldstr) {
			efree(oldstr);
		} 
		return;
		break;

At first glance, I think it should be:

	case ASSERT_CALLBACK:
		oldstr = ASSERT(callback);
		RETVAL_STRING(SAFE_STRING(oldstr),1);

		if (ac == 2) {
			convert_to_string_ex(value);
			ASSERT(callback) = estrndup((*value)->value.str.val,(*value)->value.str.len);
    		if (oldstr) {
    			efree(oldstr);
    		} 
		}
		return;
		break;

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-06 09:49 UTC] thies@php.net
fixed in CVS - thanx.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC