@@ -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 ;
@@ -130,7 +128,8 @@ PHP_METHOD(sqlite3, open)
130
128
return ;
131
129
}
132
130
} else {
133
- fullpath = estrdup (filename );
131
+ /* filename equals "" or ":memory:" */
132
+ fullpath = filename ;
134
133
}
135
134
136
135
#if SQLITE_VERSION_NUMBER >= 3005000
@@ -139,7 +138,7 @@ PHP_METHOD(sqlite3, open)
139
138
if (sqlite3_open (fullpath , & (db_obj -> db )) != SQLITE_OK ) {
140
139
#endif
141
140
zend_throw_exception_ex (zend_ce_exception , 0 , "Unable to open database: %s" , sqlite3_errmsg (db_obj -> db ));
142
- if (fullpath ) {
141
+ if (fullpath != filename ) {
143
142
efree (fullpath );
144
143
}
145
144
return ;
@@ -160,7 +159,7 @@ PHP_METHOD(sqlite3, open)
160
159
sqlite3_set_authorizer (db_obj -> db , php_sqlite3_authorizer , NULL );
161
160
}
162
161
163
- if (fullpath ) {
162
+ if (fullpath != filename ) {
164
163
efree (fullpath );
165
164
}
166
165
}
0 commit comments