diff options
author | Christoph M. Becker <cmb@php.net> | 2016-07-27 16:53:29 +0200 |
---|---|---|
committer | Christoph M. Becker <cmb@php.net> | 2016-07-27 16:54:27 +0200 |
commit | be11563fa2024b6724754a0d56f247b7f410b202 (patch) | |
tree | f324858c57c2a77ecfd78ff2df384621658297e4 /ext/sqlite3/sqlite3.c | |
parent | fab18151929c4c964d2bbe2c0c830ba82292d075 (diff) | |
parent | 23c359c27614a8b30afd860f2543912d1b297d08 (diff) | |
download | php-git-be11563fa2024b6724754a0d56f247b7f410b202.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r-- | ext/sqlite3/sqlite3.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 66a9e488b3..67b14bbb85 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -112,13 +112,11 @@ PHP_METHOD(sqlite3, open) if (db_obj->initialised) { zend_throw_exception(zend_ce_exception, "Already initialised DB Object", 0); - } - - if (strlen(filename) != filename_len) { return; } - if (filename_len != sizeof(":memory:")-1 || - memcmp(filename, ":memory:", sizeof(":memory:")-1) != 0) { + + if (filename_len != 0 && (filename_len != sizeof(":memory:")-1 || + memcmp(filename, ":memory:", sizeof(":memory:")-1) != 0)) { if (!(fullpath = expand_filepath(filename, NULL))) { zend_throw_exception(zend_ce_exception, "Unable to expand filepath", 0); return; @@ -130,7 +128,8 @@ PHP_METHOD(sqlite3, open) return; } } else { - fullpath = estrdup(filename); + /* filename equals "" or ":memory:" */ + fullpath = filename; } #if SQLITE_VERSION_NUMBER >= 3005000 @@ -139,7 +138,7 @@ PHP_METHOD(sqlite3, open) if (sqlite3_open(fullpath, &(db_obj->db)) != SQLITE_OK) { #endif zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db)); - if (fullpath) { + if (fullpath != filename) { efree(fullpath); } return; @@ -160,7 +159,7 @@ PHP_METHOD(sqlite3, open) sqlite3_set_authorizer(db_obj->db, php_sqlite3_authorizer, NULL); } - if (fullpath) { + if (fullpath != filename) { efree(fullpath); } } |