libpinyin-2.10.3-1.fc44

List of Findings

Error: CPPCHECK_WARNING (CWE-401): [#def1]
libpinyin-2.10.3/src/include/memory_chunk.h:399: error[memleakOnRealloc]: Common realloc mistake: 'm_data_begin' nulled but not freed upon failure
#  397|               return;
#  398|           size_t newsize = size();
#  399|->         m_data_begin = (char *) realloc(m_data_begin, newsize);
#  400|           m_allocated = m_data_begin + newsize;
#  401|       }

Error: COMPILER_WARNING (CWE-563): [#def2]
libpinyin-2.10.3/src/pinyin.cpp: scope_hint: In function 'bool _add_phrase(pinyin_context_t*, guint8, ChewingKeyVector, ucs4_t*, glong, gint)'
libpinyin-2.10.3/src/pinyin.cpp:541:9: warning[-Wunused-variable]: unused variable 'num'
#  541 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
#  539|       phrase_index->prepare_tokens(tokens);
#  540|       int retval = phrase_table->search(phrase_length, phrase, tokens);
#  541|->     int num = reduce_tokens(tokens, tokenarray);
#  542|       phrase_index->destroy_tokens(tokens);
#  543|   

Error: COMPILER_WARNING (CWE-563): [#def3]
libpinyin-2.10.3/src/pinyin.cpp: scope_hint: In function 'void _compute_prefixes(pinyin_instance_t*, const char*)'
libpinyin-2.10.3/src/pinyin.cpp:1415:17: warning[-Wunused-variable]: unused variable 'num'
# 1415 |             int num = reduce_tokens(tokens, tokenarray);
#      |                 ^~~
# 1413|               phrase_index->prepare_tokens(tokens);
# 1414|               int result = context->m_phrase_table->search(i, start, tokens);
# 1415|->             int num = reduce_tokens(tokens, tokenarray);
# 1416|               phrase_index->destroy_tokens(tokens);
# 1417|   

Error: COMPILER_WARNING (CWE-563): [#def4]
libpinyin-2.10.3/src/pinyin.cpp: scope_hint: In function 'bool _prepend_longer_candidates(pinyin_instance_t*, CandidateVector)'
libpinyin-2.10.3/src/pinyin.cpp:1883:9: warning[-Wunused-variable]: unused variable 'result'
# 1883 |     int result = search_suggestion_with_matrix
#      |         ^~~~~~
# 1881|       memset(tokens, 0, sizeof(tokens));
# 1882|       phrase_index->prepare_tokens(tokens);
# 1883|->     int result = search_suggestion_with_matrix
# 1884|           (context->m_pinyin_table, &matrix, prefix_len, tokens);
# 1885|       int num = reduce_tokens(tokens, tokenarray, false);

Error: COMPILER_WARNING (CWE-563): [#def5]
libpinyin-2.10.3/src/pinyin.cpp:1885:9: warning[-Wunused-variable]: unused variable 'num'
# 1885 |     int num = reduce_tokens(tokens, tokenarray, false);
#      |         ^~~
# 1883|       int result = search_suggestion_with_matrix
# 1884|           (context->m_pinyin_table, &matrix, prefix_len, tokens);
# 1885|->     int num = reduce_tokens(tokens, tokenarray, false);
# 1886|       phrase_index->destroy_tokens(tokens);
# 1887|   

Error: COMPILER_WARNING (CWE-563): [#def6]
libpinyin-2.10.3/src/pinyin.cpp: scope_hint: In function 'bool _compute_predicted_prefix_candidates(pinyin_instance_t*)'
libpinyin-2.10.3/src/pinyin.cpp:2382:9: warning[-Wunused-variable]: unused variable 'result'
# 2382 |     int result = context->m_phrase_table->search_suggestion
#      |         ^~~~~~
# 2380|       memset(phrase_tokens, 0, sizeof(phrase_tokens));
# 2381|       phrase_index->prepare_tokens(phrase_tokens);
# 2382|->     int result = context->m_phrase_table->search_suggestion
# 2383|           (instance->m_prefix_len, instance->m_prefix_ucs4, phrase_tokens);
# 2384|       int num = reduce_tokens(phrase_tokens, tokenarray, false);

Error: COMPILER_WARNING (CWE-563): [#def7]
libpinyin-2.10.3/src/pinyin.cpp:2384:9: warning[-Wunused-variable]: unused variable 'num'
# 2384 |     int num = reduce_tokens(phrase_tokens, tokenarray, false);
#      |         ^~~
# 2382|       int result = context->m_phrase_table->search_suggestion
# 2383|           (instance->m_prefix_len, instance->m_prefix_ucs4, phrase_tokens);
# 2384|->     int num = reduce_tokens(phrase_tokens, tokenarray, false);
# 2385|       phrase_index->destroy_tokens(phrase_tokens);
# 2386|   

Error: COMPILER_WARNING (CWE-563): [#def8]
libpinyin-2.10.3/src/pinyin.cpp: scope_hint: In function 'int pinyin_choose_candidate(pinyin_instance_t*, size_t, lookup_candidate_t*)'
libpinyin-2.10.3/src/pinyin.cpp:2577:10: warning[-Wunused-but-set-variable]: variable 'retval' set but not used
# 2577 |     bool retval = constraints->validate_constraint(&matrix);
#      |          ^~~~~~
# 2575|   
# 2576|       /* sync m_constraints to the length of m_pinyin_keys. */
# 2577|->     bool retval = constraints->validate_constraint(&matrix);
# 2578|   
# 2579|       phrase_token_t token = candidate->m_token;

Error: COMPILER_WARNING (CWE-563): [#def9]
libpinyin-2.10.3/src/pinyin.cpp: scope_hint: In function 'bool pinyin_lookup_tokens(pinyin_instance_t*, const char*, GArray*)'
libpinyin-2.10.3/src/pinyin.cpp:2662:9: warning[-Wunused-variable]: unused variable 'num'
# 2662 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
# 2660|       phrase_index->prepare_tokens(tokens);
# 2661|       int retval = context->m_phrase_table->search(ucs4_len, ucs4_phrase, tokens);
# 2662|->     int num = reduce_tokens(tokens, tokenarray);
# 2663|       phrase_index->destroy_tokens(tokens);
# 2664|   

Error: COMPILER_WARNING (CWE-563): [#def10]
libpinyin-2.10.3/src/pinyin.cpp: scope_hint: In function 'bool _pre_compute_tokens(pinyin_context_t*, TokenVector, ucs4_t*, size_t)'
libpinyin-2.10.3/src/pinyin.cpp:3113:13: warning[-Wunused-variable]: unused variable 'retval'
# 3113 |         int retval = phrase_table->search(1, &character, tokens);
#      |             ^~~~~~
# 3111|   
# 3112|           phrase_index->clear_tokens(tokens);
# 3113|->         int retval = phrase_table->search(1, &character, tokens);
# 3114|   
# 3115|           int num = get_first_token(tokens, token);

Error: COMPILER_WARNING (CWE-563): [#def11]
libpinyin-2.10.3/src/storage/ngram_kyotodb.cpp:26: included_from: Included from here.
libpinyin-2.10.3/src/storage/kyotodb_utils.h:50:21: warning[-Wunused-variable]: 'pinyin::empty_vbuf' defined but not used
#   50 | static const char * empty_vbuf = (char *)UINTPTR_MAX;
#      |                     ^~~~~~~~~~
#   48|   
#   49|   /* Kyoto Cabinet requires non-NULL pointer for zero length value. */
#   50|-> static const char * empty_vbuf = (char *)UINTPTR_MAX;
#   51|   
#   52|   #if 0

Error: COMPILER_WARNING (CWE-563): [#def12]
libpinyin-2.10.3/src/storage/ngram_kyotodb.cpp:26: included_from: Included from here.
libpinyin-2.10.3/src/storage/kyotodb_utils.h:50:21: warning[-Wunused-variable]: ‘pinyin::empty_vbuf’ defined but not used
#   50 | static const char * empty_vbuf = (char *)UINTPTR_MAX;
#      |                     ^~~~~~~~~~
#   48|   
#   49|   /* Kyoto Cabinet requires non-NULL pointer for zero length value. */
#   50|-> static const char * empty_vbuf = (char *)UINTPTR_MAX;
#   51|   
#   52|   #if 0

Error: CPPCHECK_WARNING (CWE-476): [#def13]
libpinyin-2.10.3/src/storage/pinyin_parser2.cpp:359: warning[nullPointer]: Possible null pointer dereference: curstep
#  357|       }
#  358|       /* prepare saving. */
#  359|->     parsed_len = curstep->m_parsed_len;
#  360|       gint16 num_keys = curstep->m_num_keys;
#  361|       g_array_set_size(keys, num_keys);

Error: CPPCHECK_WARNING (CWE-476): [#def14]
libpinyin-2.10.3/src/storage/pinyin_parser2.cpp:360: warning[nullPointer]: Possible null pointer dereference: curstep
#  358|       /* prepare saving. */
#  359|       parsed_len = curstep->m_parsed_len;
#  360|->     gint16 num_keys = curstep->m_num_keys;
#  361|       g_array_set_size(keys, num_keys);
#  362|       g_array_set_size(key_rests, num_keys);

Error: CPPCHECK_WARNING (CWE-476): [#def15]
libpinyin-2.10.3/src/storage/pinyin_parser2.cpp:365: warning[nullPointer]: Possible null pointer dereference: curstep
#  363|   
#  364|       /* save the match. */
#  365|->     while (curstep->m_last_step != -1) {
#  366|           gint16 pos = curstep->m_num_keys - 1;
#  367|   

Error: COMPILER_WARNING (CWE-563): [#def16]
libpinyin-2.10.3/src/zhuyin.cpp: scope_hint: In function 'bool _add_phrase(zhuyin_context_t*, guint8, ChewingKeyVector, ucs4_t*, glong, gint)'
libpinyin-2.10.3/src/zhuyin.cpp:427:9: warning[-Wunused-variable]: unused variable 'num'
#  427 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
#  425|       phrase_index->prepare_tokens(tokens);
#  426|       int retval = phrase_table->search(phrase_length, phrase, tokens);
#  427|->     int num = reduce_tokens(tokens, tokenarray);
#  428|       phrase_index->destroy_tokens(tokens);
#  429|   

Error: COMPILER_WARNING (CWE-563): [#def17]
libpinyin-2.10.3/src/zhuyin.cpp: scope_hint: In function 'void _compute_prefixes(zhuyin_instance_t*, const char*)'
libpinyin-2.10.3/src/zhuyin.cpp:933:17: warning[-Wunused-variable]: unused variable 'num'
#  933 |             int num = reduce_tokens(tokens, tokenarray);
#      |                 ^~~
#  931|               phrase_index->prepare_tokens(tokens);
#  932|               int result = context->m_phrase_table->search(i, start, tokens);
#  933|->             int num = reduce_tokens(tokens, tokenarray);
#  934|               phrase_index->destroy_tokens(tokens);
#  935|   

Error: COMPILER_WARNING (CWE-563): [#def18]
libpinyin-2.10.3/src/zhuyin.cpp:1638:26: warning[-Wunused-variable]: unused variable 'context'
# 1638 |     zhuyin_context_t * & context = instance->m_context;
#      |                          ^~~~~~~
# 1636|                               size_t offset,
# 1637|                               lookup_candidate_t * candidate){
# 1638|->     zhuyin_context_t * & context = instance->m_context;
# 1639|       PhoneticKeyMatrix & matrix = instance->m_matrix;
# 1640|       ForwardPhoneticConstraints * constraints = instance->m_constraints;

Error: COMPILER_WARNING (CWE-563): [#def19]
libpinyin-2.10.3/src/zhuyin.cpp:1641:25: warning[-Wunused-variable]: unused variable 'results'
# 1641 |     NBestMatchResults & results = instance->m_nbest_results;
#      |                         ^~~~~~~
# 1639|       PhoneticKeyMatrix & matrix = instance->m_matrix;
# 1640|       ForwardPhoneticConstraints * constraints = instance->m_constraints;
# 1641|->     NBestMatchResults & results = instance->m_nbest_results;
# 1642|   
# 1643|       if (BEST_MATCH_CANDIDATE == candidate->m_candidate_type)

Error: COMPILER_WARNING (CWE-563): [#def20]
libpinyin-2.10.3/src/zhuyin.cpp:1647:10: warning[-Wunused-but-set-variable]: variable 'retval' set but not used
# 1647 |     bool retval = constraints->validate_constraint(&matrix);
#      |          ^~~~~~
# 1645|   
# 1646|       /* sync m_constraints to the length of m_pinyin_keys. */
# 1647|->     bool retval = constraints->validate_constraint(&matrix);
# 1648|   
# 1649|       if (NORMAL_CANDIDATE_AFTER_CURSOR == candidate->m_candidate_type) {

Error: COMPILER_WARNING (CWE-563): [#def21]
libpinyin-2.10.3/src/zhuyin.cpp: scope_hint: In function 'int zhuyin_choose_candidate(zhuyin_instance_t*, size_t, lookup_candidate_t*)'
libpinyin-2.10.3/src/zhuyin.cpp:1651:16: warning[-Wunused-variable]: unused variable 'len'
# 1651 |         guint8 len = constraints->add_constraint
#      |                ^~~
# 1649|       if (NORMAL_CANDIDATE_AFTER_CURSOR == candidate->m_candidate_type) {
# 1650|           phrase_token_t token = candidate->m_token;
# 1651|->         guint8 len = constraints->add_constraint
# 1652|               (candidate->m_begin, candidate->m_end, token);
# 1653|           offset = candidate->m_end;

Error: COMPILER_WARNING (CWE-563): [#def22]
libpinyin-2.10.3/src/zhuyin.cpp:1658:16: warning[-Wunused-variable]: unused variable 'len'
# 1658 |         guint8 len = constraints->add_constraint
#      |                ^~~
# 1656|       if (NORMAL_CANDIDATE_BEFORE_CURSOR == candidate->m_candidate_type) {
# 1657|           phrase_token_t token = candidate->m_token;
# 1658|->         guint8 len = constraints->add_constraint
# 1659|               (candidate->m_begin, candidate->m_end, token);
# 1660|           offset = candidate->m_begin;

Error: COMPILER_WARNING (CWE-563): [#def23]
libpinyin-2.10.3/src/zhuyin.cpp: scope_hint: In function 'bool zhuyin_lookup_tokens(zhuyin_instance_t*, const char*, GArray*)'
libpinyin-2.10.3/src/zhuyin.cpp:1690:9: warning[-Wunused-variable]: unused variable 'num'
# 1690 |     int num = reduce_tokens(tokens, tokenarray);
#      |         ^~~
# 1688|       phrase_index->prepare_tokens(tokens);
# 1689|       int retval = context->m_phrase_table->search(ucs4_len, ucs4_phrase, tokens);
# 1690|->     int num = reduce_tokens(tokens, tokenarray);
# 1691|       phrase_index->destroy_tokens(tokens);
# 1692|   

Error: COMPILER_WARNING (CWE-563): [#def24]
libpinyin-2.10.3/src/zhuyin.cpp: scope_hint: In function 'bool _pre_compute_tokens(zhuyin_context_t*, TokenVector, ucs4_t*, size_t)'
libpinyin-2.10.3/src/zhuyin.cpp:2078:13: warning[-Wunused-variable]: unused variable 'retval'
# 2078 |         int retval = phrase_table->search(1, &character, tokens);
#      |             ^~~~~~
# 2076|   
# 2077|           phrase_index->clear_tokens(tokens);
# 2078|->         int retval = phrase_table->search(1, &character, tokens);
# 2079|   
# 2080|           int num = get_first_token(tokens, token);

Error: COMPILER_WARNING (CWE-195): [#def25]
libpinyin-2.10.3/tests/storage/test_phrase_table.cpp: scope_hint: In function ‘int main(int, char**)’
libpinyin-2.10.3/tests/storage/test_phrase_table.cpp:67:23: warning[-Wsign-compare]: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘glong’ {aka ‘long int’}
#   67 |         for (i = 1; i < phrase_len; ++i) {
#      |                     ~~^~~~~~~~~~~~
#   65|           /* test search continued information. */
#   66|           int retval = SEARCH_NONE;
#   67|->         for (i = 1; i < phrase_len; ++i) {
#   68|               phrase_index.clear_tokens(tokens);
#   69|               retval = largetable.search(i, new_phrase, tokens);

Error: COMPILER_WARNING (CWE-563): [#def26]
libpinyin-2.10.3/utils/segment/mergeseq.cpp: scope_hint: In function ‘bool merge_sequence(pinyin::FacadePhraseTable3*, pinyin::FacadePhraseIndex*, UnicodeCharVector, TokenInfoVector)’
libpinyin-2.10.3/utils/segment/mergeseq.cpp:99:17: warning[-Wunused-variable]: unused variable ‘num’
#   99 |             int num = get_first_token(tokens, token);
#      |                 ^~~
#   97|   
#   98|           if (retval & SEARCH_OK) {
#   99|->             int num = get_first_token(tokens, token);
#  100|               found = true;
#  101|               break;

Error: COMPILER_WARNING (CWE-563): [#def27]
libpinyin-2.10.3/utils/segment/spseg.cpp: scope_hint: In function ‘bool segment(pinyin::FacadePhraseTable3*, pinyin::FacadePhraseIndex*, GArray*, GArray*)’
libpinyin-2.10.3/utils/segment/spseg.cpp:114:17: warning[-Wunused-variable]: unused variable ‘num’
#  114 |             int num = get_first_token(tokens, token);
#      |                 ^~~
#  112|               phrase_index->clear_tokens(tokens);
#  113|               int result = phrase_table->search(len, cur_phrase, tokens);
#  114|->             int num = get_first_token(tokens, token);
#  115|   
#  116|               if ( !(result & SEARCH_OK) ){

Error: COMPILER_WARNING (CWE-563): [#def28]
libpinyin-2.10.3/utils/storage/gen_zhuyin_table.cpp: scope_hint: In function ‘void gen_phrase_file(const char*, int)’
libpinyin-2.10.3/utils/storage/gen_zhuyin_table.cpp:311:36: warning[-Wunused-but-set-variable]: variable ‘key_rest’ set but not used
#  311 |                     ChewingKeyRest key_rest = g_array_index
#      |                                    ^~~~~~~~
#  309|                   for (k = 0; k < keys->len; ++k) {
#  310|                       ChewingKey key = g_array_index(keys, ChewingKey, k);
#  311|->                     ChewingKeyRest key_rest = g_array_index
#  312|                           (key_rests, ChewingKeyRest, k);
#  313|   

Error: COMPILER_WARNING (CWE-563): [#def29]
libpinyin-2.10.3/utils/training/estimate_interpolation.cpp: scope_hint: In function ‘parameter_t compute_interpolation(pinyin::SingleGram*, pinyin::FacadePhraseIndex*, pinyin::SingleGram*)’
libpinyin-2.10.3/utils/training/estimate_interpolation.cpp:33:10: warning[-Wunused-variable]: unused variable ‘success’
#   33 |     bool success;
#      |          ^~~~~~~
#   31|   				  FacadePhraseIndex * unigram,
#   32|   				  SingleGram * bigram){
#   33|->     bool success;
#   34|       parameter_t lambda = 0, next_lambda = 0.6;
#   35|       parameter_t epsilon = 0.001;

Error: COMPILER_WARNING (CWE-563): [#def30]
libpinyin-2.10.3/utils/training/estimate_k_mixture_model.cpp: scope_hint: In function ‘parameter_t compute_interpolation(pinyin::KMixtureModelSingleGram*, pinyin::KMixtureModelBigram*, pinyin::KMixtureModelSingleGram*)’
libpinyin-2.10.3/utils/training/estimate_k_mixture_model.cpp:39:10: warning[-Wunused-variable]: unused variable ‘success’
#   39 |     bool success;
#      |          ^~~~~~~
#   37|                                     KMixtureModelBigram * unigram,
#   38|                                     KMixtureModelSingleGram * bigram){
#   39|->     bool success;
#   40|       parameter_t lambda = 0, next_lambda = 0.6;
#   41|       parameter_t epsilon = 0.001;

Error: COMPILER_WARNING (CWE-195): [#def31]
libpinyin-2.10.3/utils/training/gen_k_mixture_model.cpp: scope_hint: In function ‘void train_word_pair(HashofUnigram, pinyin::KMixtureModelSingleGram*, phrase_token_t, guint32)’
libpinyin-2.10.3/utils/training/gen_k_mixture_model.cpp:184:20: warning[-Wsign-compare]: comparison of integer expressions of different signedness: ‘guint32’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’}
#  184 |         if ( count > g_maximum_occurs ){
#      |              ~~~~~~^~~~~~~~~~~~~~~~~~
#  182|       } else { /* item doesn't exist. */
#  183|           /* the same as above. */
#  184|->         if ( count > g_maximum_occurs ){
#  185|               gpointer value = NULL;
#  186|               check_result(g_hash_table_lookup_extended

Error: COMPILER_WARNING (CWE-563): [#def32]
libpinyin-2.10.3/utils/training/gen_k_mixture_model.cpp: scope_hint: In function ‘bool post_processing_unigram(pinyin::KMixtureModelBigram*, HashofUnigram)’
libpinyin-2.10.3/utils/training/gen_k_mixture_model.cpp:302:14: warning[-Wunused-variable]: unused variable ‘result’
#  302 |         bool result = bigram->get_array_header(token, array_header);
#      |              ^~~~~~
#  300|           guint32 freq = GPOINTER_TO_UINT(value);
#  301|           KMixtureModelArrayHeader array_header;
#  302|->         bool result = bigram->get_array_header(token, array_header);
#  303|           array_header.m_freq += freq;
#  304|           total_freq += freq;

Error: COMPILER_WARNING (CWE-563): [#def33]
libpinyin-2.10.3/utils/training/prune_k_mixture_model.cpp: scope_hint: In function ‘bool prune_k_mixture_model(pinyin::KMixtureModelMagicHeader*, pinyin::KMixtureModelSingleGram*&, pinyin::FlexibleBigramPhraseArray)’
libpinyin-2.10.3/utils/training/prune_k_mixture_model.cpp:48:10: warning[-Wunused-variable]: unused variable ‘success’
#   48 |     bool success;
#      |          ^~~~~~~
#   46|                              KMixtureModelSingleGram * & bigram,
#   47|                              FlexibleBigramPhraseArray removed_array){
#   48|->     bool success;
#   49|   
#   50|       FlexibleBigramPhraseArray array = g_array_new(FALSE, FALSE, sizeof(KMixtureModelArrayItemWithToken));

Scan Properties

analyzer-version-clippy1.90.0
analyzer-version-cppcheck2.18.3
analyzer-version-gcc15.2.1
analyzer-version-gcc-analyzer16.0.0
analyzer-version-shellcheck0.11.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-32.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250521.132812.g8eff701.main-1.el9.noarch
mock-configfedora-rawhide-gcc-latest-x86_64
project-namelibpinyin-2.10.3-1.fc44
store-results-to/tmp/tmphwn8l0wd/libpinyin-2.10.3-1.fc44.tar.xz
time-created2025-10-28 19:10:27
time-finished2025-10-28 19:13:46
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'gcc,cppcheck,shellcheck,clippy,unicontrol' '-o' '/tmp/tmphwn8l0wd/libpinyin-2.10.3-1.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmphwn8l0wd/libpinyin-2.10.3-1.fc44.src.rpm'
tool-versioncsmock-3.8.3.20251027.143044.ge6b947b-1.el9