]> granicus.if.org Git - php/commitdiff
do not allow db without fields
authorAntony Dovgal <tony2001@php.net>
Sun, 25 Feb 2007 23:16:32 +0000 (23:16 +0000)
committerAntony Dovgal <tony2001@php.net>
Sun, 25 Feb 2007 23:16:32 +0000 (23:16 +0000)
fix test

ext/dbase/dbase.c
ext/dbase/tests/001.phpt
ext/dbase/tests/002.phpt

index b1d19e54f91eced0c147b1fafa4aba7cd4848127..27cde2723549d3c8423689f502dd491c666d2c46 100644 (file)
@@ -604,6 +604,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));
index 3fbb58eb21d775739ca4302923f237a89a5603b6..a483f5ff7795e54d41004de8df4bca10fafca51b 100644 (file)
@@ -54,7 +54,8 @@ bool(false)
 int(%d)
 string(71) "dbase_create(): expected field name as first element of list in field 0"
 bool(false)
-int(%d)
+string(56) "dbase_create(): Unable to create database without fields"
+bool(false)
 string(67) "Argument 2 passed to dbase_create() must be an array, integer given"
 string(50) "dbase_create(): Expected array as second parameter"
 bool(false)
index f76be4f2638664a7824e629700e71baa287898c4..d5dd5c9e02c76bda77b30fb5488234b5051a99c9 100644 (file)
@@ -35,7 +35,7 @@ var_dump(dbase_open($file, 0));
 echo "Done\n";
 ?>
 --EXPECTF--    
-Warning: dbase_open(): Invalid access mode -1 %s in %s on line %d
+Warning: dbase_open(): Invalid access mode -1 in %s on line %d
 bool(false)
 
 Warning: dbase_open(): Invalid access mode 1000 in %s on line %d