Skip to content

Commit 57eaf9f

Browse files
committed
Add Tim's suggestion
1 parent 484448a commit 57eaf9f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

ext/mysqli/mysqli_api.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ PHP_FUNCTION(mysqli_options)
11981198
zend_argument_value_error(ERROR_ARG_POS(2), "must be MYSQLI_INIT_COMMAND, MYSQLI_SET_CHARSET_NAME, MYSQLI_SERVER_PUBLIC_KEY, or one of the MYSQLI_OPT_* constants");
11991199
RETURN_THROWS();
12001200
}
1201-
1201+
12021202
if (expected_type != Z_TYPE_P(mysql_value)) {
12031203
switch (expected_type) {
12041204
case IS_STRING:
@@ -1375,13 +1375,13 @@ PHP_FUNCTION(mysqli_quote_string) {
13751375
}
13761376
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
13771377

1378-
newstr = zend_string_safe_alloc(2, escapestr_len+1, 0, 0);
1379-
ZSTR_VAL(newstr)[0] = '\'';
1380-
ZSTR_LEN(newstr) = 1 + mysql_real_escape_string(mysql->mysql, ZSTR_VAL(newstr) + 1, escapestr, escapestr_len);
1381-
ZSTR_VAL(newstr)[ZSTR_LEN(newstr)] = '\'';
1382-
ZSTR_LEN(newstr) += 1;
1383-
ZSTR_VAL(newstr)[ZSTR_LEN(newstr)] = '\0';
1384-
newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0);
1378+
newstr = zend_string_safe_alloc(2, escapestr_len, 2, 0);
1379+
char *out = ZSTR_VAL(newstr);
1380+
*out++ = '\'';
1381+
out += mysql_real_escape_string(mysql->mysql, out, escapestr, escapestr_len);
1382+
*out++ = '\'';
1383+
*out = '\0';
1384+
newstr = zend_string_truncate(newstr, out - ZSTR_VAL(newstr), 0);
13851385

13861386
RETURN_NEW_STR(newstr);
13871387
}

0 commit comments

Comments
 (0)