PHP 4.0 Bug #6552: assert_options( ASSERT_CALLBACK ) problem
| From: | blake at intechra dot net | Date: | Tue, 05 Sep 2000 14:24:33 +0000 |
| Subject: | PHP 4.0 Bug #6552: assert_options( ASSERT_CALLBACK ) problem | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-32176@lists.php.net to get a copy of this message | ||
From: blake@intechra.net
Operating system: Linux (RedHat 6.2)
PHP version: 4.0.2
PHP Bug Type: Misbehaving function
Bug description: assert_options( ASSERT_CALLBACK ) problem
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;