|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4813 dbase_create() fails with seg fault
Submitted: 2000-06-05 00:17 UTC Modified: 2000-07-02 00:43 UTC
From: greg at darkphoton dot com Assigned:
Status: Closed Package: dBase related
PHP Version: 4.0.0 Release OS: Linux Slackware 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
39 - 24 = ?
Subscribe to this entry?

 [2000-06-05 00:17 UTC] greg at darkphoton dot com
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:
	$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 );

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?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-02 00:43 UTC] sterling at cvs dot php dot net
Fixed in CVS. 

1)  Patch Applied

2)  Just fixed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 18:01:30 2024 UTC