From 17094f469536a7d0f6c558025648aaee524e0649 Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Fri, 6 May 2022 20:48:11 +0900 Subject: [PATCH] Fix GCC_ANALYZER_WARNING with -Wanalyzer-null-dereference --- anthy-unicode-HEAD.patch | 67 ++++++++++++++++++++++++++++++++++++++++ anthy-unicode.spec | 5 ++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/anthy-unicode-HEAD.patch b/anthy-unicode-HEAD.patch index c4df9e2..910cae1 100644 --- a/anthy-unicode-HEAD.patch +++ b/anthy-unicode-HEAD.patch @@ -24,3 +24,70 @@ index 14a9db4..902c7ac 100644 -- 2.33.1 +From 255323305b3621286cc4025ac59fa7d37fa1e7ce Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Fri, 6 May 2022 20:33:47 +0900 +Subject: [PATCH] src-main/context.c: Code reviews + +--- + src-main/context.c | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +diff --git a/src-main/context.c b/src-main/context.c +index 20dde71..d84858c 100644 +--- a/src-main/context.c ++++ b/src-main/context.c +@@ -451,7 +451,7 @@ anthy_get_nth_segment(struct segment_list *sl, int n) + n < 0) { + return NULL; + } +- for (i = 0, se = sl->list_head.next; i < n; i++, se = se->next); ++ for (i = 0, se = sl->list_head.next; (i < n) && se; i++, se = se->next); + return se; + } + +@@ -499,6 +499,17 @@ get_change_state(struct anthy_context *ac) + int i; + for (i = 0; i < ac->seg_list.nr_segments; i++) { + struct seg_ent *s = anthy_get_nth_segment(&ac->seg_list, i); ++ if (!ac->split_info.ce) { ++ anthy_log(0, "ac->split_info.ce is NULL %s:%d\n", __FILE__, __LINE__); ++ resize = 1; ++ break; ++ } ++ if (!s) { ++ anthy_log(0, "ac->seg_list %dth entry is NULL %s:%d\n", ++ i, __FILE__, __LINE__); ++ resize = 1; ++ continue; ++ } + if (ac->split_info.ce[s->from].initial_seg_len != s->len) { + resize = 1; + } +@@ -538,6 +549,11 @@ write_history(int fd, + struct seg_ent *s = anthy_get_nth_segment(&ac->seg_list, i); + char *c; + /**/ ++ if (!s) { ++ anthy_log(0, "ac->seg_list %dth entry is NULL %s:%d\n", ++ i, __FILE__, __LINE__); ++ continue; ++ } + if (s->committed < 0) { + dprintf(fd, "?|"); + continue ; +@@ -647,9 +663,11 @@ print_segment(struct seg_ent *e) + { + int i; + ++ assert(e); + anthy_putxstr(&e->str); + printf("("); + for ( i = 0 ; i < e->nr_cands ; i++) { ++ assert(e->cands); + anthy_print_candidate(e->cands[i]); + printf(","); + } +-- +2.35.1 + diff --git a/anthy-unicode.spec b/anthy-unicode.spec index 8e46b8f..b420a1f 100644 --- a/anthy-unicode.spec +++ b/anthy-unicode.spec @@ -10,7 +10,7 @@ Name: anthy-unicode Version: 1.0.0.20211224 -Release: 4%{?dist} +Release: 5%{?dist} # The entire source code is LGPLv2+ and dictionaries is GPLv2. the corpus data is under Public Domain. License: LGPLv2+ and GPLv2 and Public Domain URL: https://github.com/fujiwarat/anthy-unicode/wiki @@ -168,6 +168,9 @@ cd .. %changelog +* Fri May 06 2022 Takao Fujiwara 1.0.0.20211224-5 +- Fix GCC_ANALYZER_WARNING with -Wanalyzer-null-dereference + * Fri Feb 11 2022 Takao Fujiwara 1.0.0.20211224-4 - Resolves: #2051670 xemacs is a dead package