diff options
Diffstat (limited to 'src/storage/flexible_ngram.h')
-rw-r--r-- | src/storage/flexible_ngram.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/storage/flexible_ngram.h b/src/storage/flexible_ngram.h index db4436f..6cff7ff 100644 --- a/src/storage/flexible_ngram.h +++ b/src/storage/flexible_ngram.h @@ -541,6 +541,7 @@ public: */ bool get_all_items(GArray * items){ g_array_set_size(items, 0); + if ( !m_db ) return false; @@ -551,6 +552,9 @@ public: /* Get a cursor */ m_db->cursor(m_db, NULL, &cursorp, 0); + if (NULL == cursorp) + return false; + /* Initialize our DBTs. */ memset(&key, 0, sizeof(DBT)); memset(&data, 0, sizeof(DBT)); @@ -567,6 +571,10 @@ public: if ( ret != DB_NOTFOUND ){ fprintf(stderr, "training db error, exit!"); + + if (cursorp != NULL) + cursorp->c_close(cursorp); + exit(EIO); } |