fixes memory leaks
authorPeng Wu <alexepico@gmail.com>
Mon, 17 Jun 2013 07:46:24 +0000 (15:46 +0800)
committerPeng Wu <alexepico@gmail.com>
Mon, 17 Jun 2013 07:46:24 +0000 (15:46 +0800)
tests/tests_helper.h
utils/utils_helper.h

index 4f0869f..431dbc8 100644 (file)
@@ -39,6 +39,7 @@ static bool load_phrase_index(const pinyin_table_info_t * phrase_files,
         bool retval = chunk->load(filename);
         if (!retval) {
             fprintf(stderr, "open %s failed!\n", binfile);
+            delete chunk;
             return false;
         }
 
index be4f05f..86d5849 100644 (file)
@@ -109,6 +109,7 @@ static bool save_phrase_index(const pinyin_table_info_t * phrase_files,
         bool retval = new_chunk->save(binfile);
         if (!retval) {
             fprintf(stderr, "save %s failed.", binfile);
+            delete new_chunk;
             return false;
         }
 
@@ -133,6 +134,7 @@ static bool save_dictionary(const pinyin_table_info_t * phrase_files,
         bool retval = new_chunk->save(binfile);
         if (!retval) {
             fprintf(stderr, "save %s failed.", binfile);
+            delete new_chunk;
             return false;
         }