summaryrefslogtreecommitdiff
path: root/ext/sqlite3/sqlite3.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-10-17 16:58:49 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2016-10-17 23:34:41 +0200
commit86e603a664afdc3a12ead0eaca5d37fa8a379381 (patch)
treefeea44fc88e7ba7aa6b5273d9bd81f0632709e2a /ext/sqlite3/sqlite3.c
parente1f5b6d8dfe1543205d5b45d3dcf1d34f5e2e420 (diff)
downloadphp-git-86e603a664afdc3a12ead0eaca5d37fa8a379381.tar.gz
Fix #73333: 2147483647 is fetched as string
We return all integers that can be represented as such by PHP as integers, and only those that exceed the possible range as strings. On builds which represent integers with 64 bits, the range check is unnecessary and might cause code checkers to complain, so we skip this special casing via the preprocessor according to <http://git.php.net/?p=php-src.git;a=commit;h=99d087e5>.
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r--ext/sqlite3/sqlite3.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 54ec73d6ac..80d6b897f1 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -591,14 +591,21 @@ PHP_METHOD(sqlite3, query)
static zval* sqlite_value_to_zval(sqlite3_stmt *stmt, int column) /* {{{ */
{
zval *data;
+ sqlite3_int64 val;
+
MAKE_STD_ZVAL(data);
switch (sqlite3_column_type(stmt, column)) {
case SQLITE_INTEGER:
- if ((sqlite3_column_int64(stmt, column)) >= INT_MAX || sqlite3_column_int64(stmt, column) <= INT_MIN) {
+ val = sqlite3_column_int64(stmt, column);
+#if LONG_MAX <= 2147483647
+ if (val > LONG_MAX || val < LONG_MIN) {
ZVAL_STRINGL(data, (char *)sqlite3_column_text(stmt, column), sqlite3_column_bytes(stmt, column), 1);
} else {
- ZVAL_LONG(data, sqlite3_column_int64(stmt, column));
+#endif
+ ZVAL_LONG(data, val);
+#if LONG_MAX <= 2147483647
}
+#endif
break;
case SQLITE_FLOAT: