Skip to content

Commit 7af4029

Browse files
committed
make suggested simplifications
the PDO_DBLIB change predates the PDO_BINARY proposa, so...
1 parent 881c0f0 commit 7af4029

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

ext/pdo_dblib/dblib_driver.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const zend_string *sql)
145145
static zend_string* dblib_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype)
146146
{
147147
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
148-
bool use_national_character_set = 0, is_binary = false;
148+
bool use_national_character_set = 0;
149149
size_t i;
150150
char *q;
151151
size_t quotedlen = 0;
@@ -166,15 +166,8 @@ static zend_string* dblib_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquo
166166
* binary literal instead.
167167
*/
168168
if (paramtype == PDO_PARAM_BINARY) {
169-
is_binary = true;
170-
}
171-
172-
if (is_binary) {
173169
/* 1 char = 2 chars in hex, plus 0x */
174-
quotedlen = ZSTR_LEN(unquoted) * 2; /* XXX: Overflow? */
175-
quotedlen += 2;
176-
177-
quoted_str = zend_string_alloc(quotedlen, 0);
170+
quoted_str = zend_string_safe_alloc(ZSTR_LEN(unquoted), 2, 2, false);
178171
q = ZSTR_VAL(quoted_str);
179172
*q++ = '0';
180173
*q++ = 'x';

0 commit comments

Comments
 (0)