diff options
author | Anatol Belski <ab@php.net> | 2017-07-09 01:31:25 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-07-09 01:31:25 +0200 |
commit | 02cc492015078b28c14d74b7eb0aad0442375550 (patch) | |
tree | d656d0144a488effb418fc17bd5449b2998ee7c0 /ext/sqlite3/sqlite3.c | |
parent | b38de96733eef6fb005a198e1ce59862043b97a2 (diff) | |
parent | b5338c0b7d145d9b5b5abcb9d695691ca5d6e418 (diff) | |
download | php-git-02cc492015078b28c14d74b7eb0aad0442375550.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
Fixed bug #74883 SQLite3::__construct() produces "out of memory" exception with invalid flags
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r-- | ext/sqlite3/sqlite3.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 7eb86d4a57..45a1b847bf 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -103,6 +103,7 @@ PHP_METHOD(sqlite3, open) char *filename, *encryption_key, *fullpath; size_t filename_len, encryption_key_len = 0; zend_long flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; + int rc; db_obj = Z_SQLITE3_DB_P(object); @@ -133,11 +134,13 @@ PHP_METHOD(sqlite3, open) } #if SQLITE_VERSION_NUMBER >= 3005000 - if (sqlite3_open_v2(fullpath, &(db_obj->db), flags, NULL) != SQLITE_OK) { + rc = sqlite3_open_v2(fullpath, &(db_obj->db), flags, NULL); #else - if (sqlite3_open(fullpath, &(db_obj->db)) != SQLITE_OK) { + rc = sqlite3_open(fullpath, &(db_obj->db)); #endif - zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db)); + if (rc != SQLITE_OK) { + zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", + db_obj->db ? sqlite3_errmsg(db_obj->db) : sqlite3_errstr(rc)); if (fullpath != filename) { efree(fullpath); } |