Skip to content

Commit ef36de1

Browse files
committed
Use zend_string_equals() in PDO
Closes GH-6623
1 parent 6bc7f62 commit ef36de1

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_
297297
int i;
298298

299299
for (i = 0; i < stmt->column_count; i++) {
300-
if (ZSTR_LEN(stmt->columns[i].name) == ZSTR_LEN(param->name) &&
301-
strncmp(ZSTR_VAL(stmt->columns[i].name), ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1) == 0) {
300+
if (zend_string_equals(stmt->columns[i].name, param->name)) {
302301
param->paramno = i;
303302
break;
304303
}
@@ -2276,8 +2275,7 @@ static zval *row_prop_read(zend_object *object, zend_string *name, int type, voi
22762275
/* TODO: replace this with a hash of available column names to column
22772276
* numbers */
22782277
for (colno = 0; colno < stmt->column_count; colno++) {
2279-
if (ZSTR_LEN(stmt->columns[colno].name) == ZSTR_LEN(name) &&
2280-
strncmp(ZSTR_VAL(stmt->columns[colno].name), ZSTR_VAL(name), ZSTR_LEN(name)) == 0) {
2278+
if (zend_string_equals(stmt->columns[colno].name, name)) {
22812279
fetch_value(stmt, rv, colno, NULL);
22822280
return rv;
22832281
}
@@ -2317,8 +2315,7 @@ static zval *row_dim_read(zend_object *object, zval *member, int type, zval *rv)
23172315
/* TODO: replace this with a hash of available column names to column
23182316
* numbers */
23192317
for (colno = 0; colno < stmt->column_count; colno++) {
2320-
if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) &&
2321-
strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) {
2318+
if (zend_string_equals(stmt->columns[colno].name, Z_STR_P(member))) {
23222319
fetch_value(stmt, rv, colno, NULL);
23232320
return rv;
23242321
}
@@ -2358,16 +2355,15 @@ static int row_prop_exists(zend_object *object, zend_string *name, int check_emp
23582355
/* TODO: replace this with a hash of available column names to column
23592356
* numbers */
23602357
for (colno = 0; colno < stmt->column_count; colno++) {
2361-
if (ZSTR_LEN(stmt->columns[colno].name) == ZSTR_LEN(name) &&
2362-
strncmp(ZSTR_VAL(stmt->columns[colno].name), ZSTR_VAL(name), ZSTR_LEN(name)) == 0) {
2363-
int res;
2364-
zval val;
2358+
if (zend_string_equals(stmt->columns[colno].name, name)) {
2359+
int res;
2360+
zval val;
23652361

2366-
fetch_value(stmt, &val, colno, NULL);
2367-
res = check_empty ? i_zend_is_true(&val) : Z_TYPE(val) != IS_NULL;
2368-
zval_ptr_dtor_nogc(&val);
2362+
fetch_value(stmt, &val, colno, NULL);
2363+
res = check_empty ? i_zend_is_true(&val) : Z_TYPE(val) != IS_NULL;
2364+
zval_ptr_dtor_nogc(&val);
23692365

2370-
return res;
2366+
return res;
23712367
}
23722368
}
23732369
}
@@ -2398,16 +2394,15 @@ static int row_dim_exists(zend_object *object, zval *member, int check_empty)
23982394
/* TODO: replace this with a hash of available column names to column
23992395
* numbers */
24002396
for (colno = 0; colno < stmt->column_count; colno++) {
2401-
if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) &&
2402-
strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) {
2403-
int res;
2404-
zval val;
2397+
if (zend_string_equals(stmt->columns[colno].name, Z_STR_P(member))) {
2398+
int res;
2399+
zval val;
24052400

2406-
fetch_value(stmt, &val, colno, NULL);
2407-
res = check_empty ? i_zend_is_true(&val) : Z_TYPE(val) != IS_NULL;
2408-
zval_ptr_dtor_nogc(&val);
2401+
fetch_value(stmt, &val, colno, NULL);
2402+
res = check_empty ? i_zend_is_true(&val) : Z_TYPE(val) != IS_NULL;
2403+
zval_ptr_dtor_nogc(&val);
24092404

2410-
return res;
2405+
return res;
24112406
}
24122407
}
24132408
}

0 commit comments

Comments
 (0)