libchewing
libchewing copied to clipboard
assert fail in SetChoiceInfo()
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=118
input
$ xxd -r > assert-SetChoiceInfo-nTotalChoice
00000000: c201 cb01 7171 7171 7171 1630 3000 7171 ....qqqqqq.00.qq
00000010: 1371 .q
how to reproduce:
$ ./test/stress -stdin -loop 1 -extra -file assert-SetChoiceInfo-nTotalChoice -verbose
stress: choice.c:307: void SetChoiceInfo(ChewingData *): Assertion `pci->nTotalChoice > 0' failed.
What did it do:
- switch to Hsu keyboard
- keyin "jjjjjj" (至至至)
- press Ctrl-3 (save user phrase size=3)
- keyin "$$" (two $ symbol)
- press [Left]
- keyin "jj" (至)
- press Ctrl-0 (symbol input) (Ctrl-1 is okay if you cannot press Ctrl-0)
- keyin "j"
How to reproduce using standard keyboard layout:
- keyin "545454" (至至至)
- press Ctrl-3
- keyin "$$"
- press [Left]
- keyin "54" (至)
- press Ctrl-0 or Ctrl-1
- keyin "j"
You can also reproduce with ./test/genkeystroke
@czchen could you take a look?
I found you add this assertion. assert( pci->nTotalChoice > 0 );
https://github.com/chewing/libchewing/commit/98afedfb0dde6a228873d3a41081c7937f3493d4
I'm wondering did you really mean assert( pci->nTotalChoice > 0 ); or you actually want to assert(pci->nChoicePerPage > 0); since the next line is CEIL_DIV(pci->nTotalChoice, pci->nChoicePerPage)