Merge pull request #4 from metasequoiaime/fix/dictionary-buffer-leaks

fix(decoder): 释放词典缓冲区并加入 Linux 泄漏检测
This commit is contained in:
Evan
2026-09-06 10:54:06 +09:00
committed by GitHub
3 changed files with 25 additions and 2 deletions
+20
View File
@@ -33,3 +33,23 @@ jobs:
run: cmake --build build --config Release --parallel 4
- name: Run regression tests
run: ctest --test-dir build -C Release --output-on-failure --no-tests=error --timeout 30
sanitizers:
name: Linux ASan and UBSan
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Configure
run: >-
cmake -S tests -B build-sanitizers -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer"
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined"
- name: Build
run: cmake --build build-sanitizers --parallel 4
- name: Run regression tests
env:
ASAN_OPTIONS: detect_leaks=1:halt_on_error=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
run: ctest --test-dir build-sanitizers --output-on-failure --no-tests=error --timeout 30
+2 -2
View File
@@ -56,8 +56,8 @@ void DictTrie::free_resource(bool free_dict_list) {
if (NULL != nodes_ge1_) free(nodes_ge1_);
nodes_ge1_ = NULL;
if (NULL != nodes_ge1_) free(nodes_ge1_);
nodes_ge1_ = NULL;
if (NULL != lma_idx_buf_) free(lma_idx_buf_);
lma_idx_buf_ = NULL;
if (free_dict_list) {
if (NULL != dict_list_) {
+3
View File
@@ -336,6 +336,9 @@ out:
free(offsets_by_id_);
free(scores_);
free(ids_);
#ifdef ___SYNC_ENABLED___
free(syncs_);
#endif
#ifdef ___PREDICT_ENABLED___
free(predicts_);
#endif