]> granicus.if.org Git - php/commitdiff
Fix null handling in mysqli_begin_transaction()
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 13 Oct 2020 15:10:41 +0000 (17:10 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 13 Oct 2020 15:12:50 +0000 (17:12 +0200)
We don't want an explicit null name hit the !name_len check.

ext/mysqli/mysqli_nonapi.c

index 5bbb1d38888cd191363e5c98d69b7b786763a33d..c75527ff93bed55718043ec32d1de90637917d9f 100644 (file)
@@ -1160,7 +1160,7 @@ PHP_FUNCTION(mysqli_begin_transaction)
        zval            *mysql_link;
        zend_long               flags = TRANS_START_NO_OPT;
        char *          name = NULL;
-       size_t                  name_len = -1;
+       size_t                  name_len = 0;
 
        if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls!", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
                RETURN_THROWS();
@@ -1170,7 +1170,7 @@ PHP_FUNCTION(mysqli_begin_transaction)
                zend_argument_value_error(ERROR_ARG_POS(2), "must be one of the MYSQLI_TRANS_* constants");
                RETURN_THROWS();
        }
-       if (!name_len) {
+       if (name && !name_len) {
                zend_argument_value_error(ERROR_ARG_POS(3), "cannot be empty");
                RETURN_THROWS();
        }