summaryrefslogtreecommitdiff
path: root/ext/sqlite3/sqlite3.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
-rw-r--r--ext/sqlite3/sqlite3.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 2cb6a5225c..9c14dabc66 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;
@@ -138,7 +136,8 @@ PHP_METHOD(sqlite3, open)
return;
}
} else {
- fullpath = estrdup(filename);
+ /* filename equals "" or ":memory:" */
+ fullpath = filename;
}
#if SQLITE_VERSION_NUMBER >= 3005000
@@ -147,7 +146,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;
@@ -172,7 +171,7 @@ PHP_METHOD(sqlite3, open)
sqlite3_set_authorizer(db_obj->db, php_sqlite3_authorizer, NULL);
}
- if (fullpath) {
+ if (fullpath != filename) {
efree(fullpath);
}
}