summaryrefslogtreecommitdiff
path: root/ext/sqlite3/sqlite3.c
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-12-03 21:05:44 (GMT)
committerFelipe Pena <felipe@php.net>2010-12-03 21:05:44 (GMT)
commit26d7aafb1a76093eb85d0edb222fadadea37beec (patch)
treede8ed47976ea872a0db2669954a2ed98de4d8d6b /ext/sqlite3/sqlite3.c
parent17d1b1310ef07dfdf3f841cbe09cf36348530a7e (diff)
downloadphp-26d7aafb1a76093eb85d0edb222fadadea37beec.tar.gz
- Fixed bug #53463 (sqlite3 columnName() segfaults on bad column_number)
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r--ext/sqlite3/sqlite3.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 949900c..2937fc7 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -1529,6 +1529,7 @@ PHP_METHOD(sqlite3result, columnName)
php_sqlite3_result *result_obj;
zval *object = getThis();
long column = 0;
+ char *column_name;
result_obj = (php_sqlite3_result *)zend_object_store_get_object(object TSRMLS_CC);
SQLITE3_CHECK_INITIALIZED(result_obj->db_obj, result_obj->stmt_obj->initialised, SQLite3Result)
@@ -1536,8 +1537,13 @@ PHP_METHOD(sqlite3result, columnName)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &column) == FAILURE) {
return;
}
+ column_name = (char*) sqlite3_column_name(result_obj->stmt_obj->stmt, column);
- RETVAL_STRING((char*)sqlite3_column_name(result_obj->stmt_obj->stmt, column), 1);
+ if (column_name == NULL) {
+ RETURN_FALSE;
+ }
+
+ RETVAL_STRING(column_name, 1);
}
/* }}} */