@@ -112,13 +112,11 @@ PHP_METHOD(sqlite3, open)
112
112
113
113
if (db_obj -> initialised ) {
114
114
zend_throw_exception (zend_ce_exception , "Already initialised DB Object" , 0 );
115
- }
116
-
117
- if (strlen (filename ) != filename_len ) {
118
115
return ;
119
116
}
120
- if (filename_len != sizeof (":memory:" )- 1 ||
121
- memcmp (filename , ":memory:" , sizeof (":memory:" )- 1 ) != 0 ) {
117
+
118
+ if (filename_len != 0 && (filename_len != sizeof (":memory:" )- 1 ||
119
+ memcmp (filename , ":memory:" , sizeof (":memory:" )- 1 ) != 0 )) {
122
120
if (!(fullpath = expand_filepath (filename , NULL ))) {
123
121
zend_throw_exception (zend_ce_exception , "Unable to expand filepath" , 0 );
124
122
return ;
@@ -138,7 +136,8 @@ PHP_METHOD(sqlite3, open)
138
136
return ;
139
137
}
140
138
} else {
141
- fullpath = estrdup (filename );
139
+ /* filename equals "" or ":memory:" */
140
+ fullpath = filename ;
142
141
}
143
142
144
143
#if SQLITE_VERSION_NUMBER >= 3005000
@@ -147,7 +146,7 @@ PHP_METHOD(sqlite3, open)
147
146
if (sqlite3_open (fullpath , & (db_obj -> db )) != SQLITE_OK ) {
148
147
#endif
149
148
zend_throw_exception_ex (zend_ce_exception , 0 , "Unable to open database: %s" , sqlite3_errmsg (db_obj -> db ));
150
- if (fullpath ) {
149
+ if (fullpath != filename ) {
151
150
efree (fullpath );
152
151
}
153
152
return ;
@@ -172,7 +171,7 @@ PHP_METHOD(sqlite3, open)
172
171
sqlite3_set_authorizer (db_obj -> db , php_sqlite3_authorizer , NULL );
173
172
}
174
173
175
- if (fullpath ) {
174
+ if (fullpath != filename ) {
176
175
efree (fullpath );
177
176
}
178
177
}
0 commit comments