fix(decoder): 释放词典索引与同步缓冲区并加入泄漏检测

This commit is contained in:
Evan Hu
2026-09-06 10:38:23 +09:00
parent 2f3cf9f06c
commit 5d11ae41df
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 run: cmake --build build --config Release --parallel 4
- name: Run regression tests - name: Run regression tests
run: ctest --test-dir build -C Release --output-on-failure --no-tests=error --timeout 30 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_); if (NULL != nodes_ge1_) free(nodes_ge1_);
nodes_ge1_ = NULL; nodes_ge1_ = NULL;
if (NULL != nodes_ge1_) free(nodes_ge1_); if (NULL != lma_idx_buf_) free(lma_idx_buf_);
nodes_ge1_ = NULL; lma_idx_buf_ = NULL;
if (free_dict_list) { if (free_dict_list) {
if (NULL != dict_list_) { if (NULL != dict_list_) {
+3
View File
@@ -336,6 +336,9 @@ out:
free(offsets_by_id_); free(offsets_by_id_);
free(scores_); free(scores_);
free(ids_); free(ids_);
#ifdef ___SYNC_ENABLED___
free(syncs_);
#endif
#ifdef ___PREDICT_ENABLED___ #ifdef ___PREDICT_ENABLED___
free(predicts_); free(predicts_);
#endif #endif