diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 482baf3..59490eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/src/share/dicttrie.cpp b/src/share/dicttrie.cpp index 8c7d6d7..cf6360b 100644 --- a/src/share/dicttrie.cpp +++ b/src/share/dicttrie.cpp @@ -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_) { diff --git a/src/share/userdict.cpp b/src/share/userdict.cpp index ac6f08c..a3df536 100644 --- a/src/share/userdict.cpp +++ b/src/share/userdict.cpp @@ -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