PHP 4.0 Bug #4813: dbase_create() fails with seg fault
| From: | greg at darkphoton dot com | Date: | Sun, 04 Jun 2000 22:17:44 +0000 |
| Subject: | PHP 4.0 Bug #4813: dbase_create() fails with seg fault | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-20211@lists.php.net to get a copy of this message | ||
From: greg@darkphoton.com
Operating system: Linux Slackware 7
PHP version: 4.0.0 Release
PHP Bug Type: dBase related
Bug description: dbase_create() fails with seg fault
dbase_create has two problems:
1) it segfaults if dbh has been created but no feilds are added and then needs to bail due to an
error. The following code needs to be added to line 622 (in the release code base) or just above
the field loop:
/* make sure that the db_format entries for all fields are set to NULL to ensure we
don't seg fault if there's an error and we need to call free_dbf_head() before all
fields have been defined */
for (i = 0, cur_f = dbf; i < num_fields; i++, cur_f++) {
cur_f->db_format = NULL;
}
2) it does not recognize the array of array's correctly in the second parameter. Here is my
test code:
--code--
$dbdef = array(
array( "id", "N", 5 , 0 ),
array( "owner", "C", 20 ),
array( "groupname", "C", 100 ),
array( "type", "C", 20 )
);
dbase_create( "/tmp/test.dbf", $dbdef );
--code--
which generates the following error message:
<b>Warning</b>: second parameter must be array of arrays in
<b>dbase-test.php</b> on line <b>9</b><br>
zend_hash_index_find() on line 626 claims success, however then field->type is set to 0 which is
a null value, not an array.
I've tried the above with both a 'production' 4.0.0 server with lots of modules
compiled in and a fresh cgi version with only --with-dbase enabled and get the same result.
The above code works fine in php 3.0.x and the dbase_create functions between 3 and 4 really
don't seem to have changed, I'm wondering if there is a problem in passing array's or
array's as a parameter?