diff options
| author | Antony Dovgal <tony2001@php.net> | 2007-02-25 23:17:12 +0000 |
|---|---|---|
| committer | Antony Dovgal <tony2001@php.net> | 2007-02-25 23:17:12 +0000 |
| commit | fb3a3b72f19c891b1e29f440c8108e6965b1b25b (patch) | |
| tree | 3b92fd7d170457f8ab147b4cdd0f7f60418d7fd8 /ext/dbase | |
| parent | b42addcc548797b2b44b0d9f089d5531986f59b4 (diff) | |
| download | php-git-fb3a3b72f19c891b1e29f440c8108e6965b1b25b.tar.gz | |
MFH: do not allow db without fields
Diffstat (limited to 'ext/dbase')
| -rw-r--r-- | ext/dbase/dbase.c | 5 | ||||
| -rw-r--r-- | ext/dbase/tests/001.phpt | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/ext/dbase/dbase.c b/ext/dbase/dbase.c index 6c13bb6dcc..eb1963e3f2 100644 --- a/ext/dbase/dbase.c +++ b/ext/dbase/dbase.c @@ -621,6 +621,11 @@ PHP_FUNCTION(dbase_create) num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); + if (num_fields <= 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create database without fields"); + RETURN_FALSE; + } + /* have to use regular malloc() because this gets free()d by code in the dbase library */ dbh = (dbhead_t *)malloc(sizeof(dbhead_t)); diff --git a/ext/dbase/tests/001.phpt b/ext/dbase/tests/001.phpt index 51a4488708..7c10efb267 100644 --- a/ext/dbase/tests/001.phpt +++ b/ext/dbase/tests/001.phpt @@ -51,7 +51,9 @@ int(%d) Warning: dbase_create(): expected field name as first element of list in field 0 in %s on line %d bool(false) -int(%d) + +Warning: dbase_create(): Unable to create database without fields in %s on line %d +bool(false) Warning: dbase_create(): Expected array as second parameter in %s on line %d bool(false) |
