Skip to content

Commit 4b52075

Browse files
committed
Maybe it's attr_get() messing stuff
1 parent b9c07cc commit 4b52075

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ext/mysqli/mysqli_api.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,20 +2292,18 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
22922292
zval *mysql_stmt;
22932293
unsigned long value = 0;
22942294
zend_long attr;
2295+
int rc;
22952296

22962297
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &attr) == FAILURE) {
22972298
RETURN_THROWS();
22982299
}
22992300
MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
23002301

2301-
switch (attr) {
2302+
if (attr != STMT_ATTR_CURSOR_TYPE && attr != STMT_ATTR_PREFETCH_ROWS
23022303
#if MYSQL_VERSION_ID >= 50107
2303-
case STMT_ATTR_UPDATE_MAX_LENGTH:
2304+
&& attr != STMT_ATTR_UPDATE_MAX_LENGTH
23042305
#endif
2305-
case STMT_ATTR_CURSOR_TYPE:
2306-
case STMT_ATTR_PREFETCH_ROWS:
2307-
break;
2308-
default:
2306+
) {
23092307
zend_argument_value_error(ERROR_ARG_POS(2), "must be one of "
23102308
#if MYSQL_VERSION_ID >= 50107
23112309
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, "
@@ -2314,9 +2312,12 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
23142312
RETURN_THROWS();
23152313
}
23162314

2317-
/* Success corresponds to 0 return value and a non-zero value
2318-
* should only happen if the attr/option is unknown */
2319-
ZEND_ASSERT(mysql_stmt_attr_get(stmt->stmt, attr, &value) == 0);
2315+
if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2316+
/* Success corresponds to 0 return value and a non-zero value
2317+
* should only happen if the attr/option is unknown */
2318+
ZEND_UNREACHABLE();
2319+
}
2320+
23202321

23212322
#if MYSQL_VERSION_ID >= 50107
23222323
if (attr == STMT_ATTR_UPDATE_MAX_LENGTH)

0 commit comments

Comments
 (0)