Merge pull request #157 from t8m/close-crash
Do not crash in commonio_close if database FILE not opened.
This commit is contained in:
commit
e24deea4c9
@ -925,7 +925,6 @@ static int write_all (const struct commonio_db *db)
|
|||||||
|
|
||||||
|
|
||||||
int commonio_close (struct commonio_db *db)
|
int commonio_close (struct commonio_db *db)
|
||||||
/*@requires notnull db->fp@*/
|
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
@ -938,8 +937,10 @@ int commonio_close (struct commonio_db *db)
|
|||||||
db->isopen = false;
|
db->isopen = false;
|
||||||
|
|
||||||
if (!db->changed || db->readonly) {
|
if (!db->changed || db->readonly) {
|
||||||
(void) fclose (db->fp);
|
if (NULL != db->fp) {
|
||||||
db->fp = NULL;
|
(void) fclose (db->fp);
|
||||||
|
db->fp = NULL;
|
||||||
|
}
|
||||||
goto success;
|
goto success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user