(database_info.c) Add some error handling

This commit is contained in:
twinaphex 2015-05-28 02:22:50 +02:00
parent 8bde46deb9
commit 99ea729d1c
2 changed files with 14 additions and 2 deletions

View File

@ -227,11 +227,20 @@ static int database_cursor_open(libretrodb_t *db,
strlen(query), &error);
if (error)
return -1;
goto error;
if ((libretrodb_cursor_open(db, cur, q)) != 0)
return -1;
goto error;
return 0;
error:
if (query)
libretrodb_query_free(q);
query = NULL;
libretrodb_close(db);
db = NULL;
return -1;
}
static int database_cursor_close(libretrodb_t *db, libretrodb_cursor_t *cur)

View File

@ -141,6 +141,9 @@ static void libretrodb_write_index_header(int fd, libretrodb_index_t * idx)
void libretrodb_close(libretrodb_t *db)
{
if (!db)
return;
close(db->fd);
db->fd = -1;
}