Skip to content

Commit eb3370c

Browse files
committed
returning NULL with no explanation is not cool
1 parent 50dc301 commit eb3370c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ext/pdo_sqlite/sqlite_driver.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,17 @@ static zend_string *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const zend_string
227227
static zend_string* sqlite_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype)
228228
{
229229
char *quoted;
230-
if (ZSTR_LEN(unquoted) > (INT_MAX - 3) / 2) {
230+
231+
if (UNEXPECTED(ZSTR_LEN(unquoted) > (INT_MAX - 3) / 2)) {
232+
if (dbh->error_mode == PDO_ERRMODE_EXCEPTION) {
233+
zend_throw_exception_ex(
234+
php_pdo_get_exception(), 0,
235+
"SQLite PDO::quote: string is too long to quote");
236+
} else if (dbh->error_mode == PDO_ERRMODE_WARNING) {
237+
php_error_docref(
238+
NULL, E_WARNING,
239+
"SQLite PDO::quote: string is too long to quote");
240+
}
231241
return NULL;
232242
}
233243

0 commit comments

Comments
 (0)