libchewing icon indicating copy to clipboard operation
libchewing copied to clipboard

assert fail in SetChoiceInfo()

Open kcwu opened this issue 9 years ago • 1 comments

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:

  1. switch to Hsu keyboard
  2. keyin "jjjjjj" (至至至)
  3. press Ctrl-3 (save user phrase size=3)
  4. keyin "$$" (two $ symbol)
  5. press [Left]
  6. keyin "jj" (至)
  7. press Ctrl-0 (symbol input) (Ctrl-1 is okay if you cannot press Ctrl-0)
  8. keyin "j"

How to reproduce using standard keyboard layout:

  1. keyin "545454" (至至至)
  2. press Ctrl-3
  3. keyin "$$"
  4. press [Left]
  5. keyin "54" (至)
  6. press Ctrl-0 or Ctrl-1
  7. keyin "j"

You can also reproduce with ./test/genkeystroke

kcwu avatar Nov 23 '16 11:11 kcwu

@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)

kcwu avatar Nov 23 '16 11:11 kcwu