diff options
| author | czxdev <36617515+czxdev@users.noreply.github.com> | 2025-04-29 11:43:41 +0800 |
|---|---|---|
| committer | Peng Wu <alexepico@gmail.com> | 2025-05-07 10:47:21 +0800 |
| commit | f3e720527c42179058f82b0024d1eef737de88b5 (patch) | |
| tree | db3e89b2f6b5f428b13c8ace6c21d270b42b0301 | |
| parent | a6f4d3c239883b5e1dd0770ab2b433042845e9c9 (diff) | |
| download | libpinyin-f3e720527c42179058f82b0024d1eef737de88b5.tar.gz libpinyin-f3e720527c42179058f82b0024d1eef737de88b5.tar.xz libpinyin-f3e720527c42179058f82b0024d1eef737de88b5.zip | |
Fix memory leaks in kyotodb based tables
| -rw-r--r-- | src/storage/chewing_large_table2_kyotodb.cpp | 5 | ||||
| -rw-r--r-- | src/storage/phrase_large_table3_kyotodb.cpp | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/storage/chewing_large_table2_kyotodb.cpp b/src/storage/chewing_large_table2_kyotodb.cpp index d5aeeb9..3b1de61 100644 --- a/src/storage/chewing_large_table2_kyotodb.cpp +++ b/src/storage/chewing_large_table2_kyotodb.cpp @@ -568,6 +568,7 @@ int ChewingLargeTable2::search_suggestion result = search_suggestion_internal (phrase_length, chunk, prefix_len, prefix_keys, tokens) | result; chunk.set_size(0); + delete [] bkbuf; delete [] bvbuf; retval = cursor->step(); @@ -580,6 +581,10 @@ int ChewingLargeTable2::search_suggestion bkbuf = cursor->get_key(&bksiz); } + if (bkbuf) { + delete [] bkbuf; + } + delete cursor; return result; } diff --git a/src/storage/phrase_large_table3_kyotodb.cpp b/src/storage/phrase_large_table3_kyotodb.cpp index f4b6faa..432ae5b 100644 --- a/src/storage/phrase_large_table3_kyotodb.cpp +++ b/src/storage/phrase_large_table3_kyotodb.cpp @@ -230,6 +230,7 @@ int PhraseLargeTable3::search_suggestion(int phrase_length, m_entry->m_chunk.set_chunk(bvbuf, bvsiz, NULL); result = m_entry->search(tokens) | result; m_entry->m_chunk.set_size(0); + delete [] bkbuf; delete [] bvbuf; retval = cursor->step(); @@ -242,6 +243,10 @@ int PhraseLargeTable3::search_suggestion(int phrase_length, bkbuf = cursor->get_key(&bksiz); } + if (bkbuf) { + delete [] bkbuf; + } + delete cursor; return result; } |
