]> granicus.if.org Git - php/commitdiff
Fix potential crash when non-array is used optimisticly
authorSara Golemon <pollita@php.net>
Thu, 24 Jan 2008 10:27:59 +0000 (10:27 +0000)
committerSara Golemon <pollita@php.net>
Thu, 24 Jan 2008 10:27:59 +0000 (10:27 +0000)
ext/dbase/dbase.c

index ca19cb16faab08e870952abecbe4ca882250be2b..ad8be033bbc908ee60fb6ae59651e890d409c8b8 100644 (file)
@@ -270,6 +270,11 @@ PHP_FUNCTION(dbase_add_record)
        }
        convert_to_long_ex(dbh_id);
 
+       if (Z_TYPE_PP(fields) != IS_ARRAY) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument two must be of type 'Array'");
+               RETURN_FALSE;
+       }
+
        dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
        if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));
@@ -337,6 +342,11 @@ PHP_FUNCTION(dbase_replace_record)
        convert_to_long_ex(dbh_id);
        convert_to_long_ex(recnum);
 
+       if (Z_TYPE_PP(fields) != IS_ARRAY) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument two must be of type 'Array'");
+               RETURN_FALSE;
+       }
+
        dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
        if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id));