Skip to content

fix: In decodeUnicode, the case that the expected buffer's state is not satisfied after reading.#380

Merged
goccy merged 2 commits intogoccy:masterfrom
orisano:fix/#374
Jul 9, 2022
Merged

fix: In decodeUnicode, the case that the expected buffer's state is not satisfied after reading.#380
goccy merged 2 commits intogoccy:masterfrom
orisano:fix/#374

Conversation

@orisano
Copy link
Copy Markdown
Contributor

@orisano orisano commented Jul 6, 2022

fix #374

io.MultiReaderなどを使うケースでReadをしてもio.EOFでなく要求したバイト数取得できないケースが存在する.
その際にfilledBufferがfalseになる. filledBufferがfalseの場合, bufferを拡張する処理が動かないため再利用の処理のみが実行される.
decodeUnicodeRuneの内部においてbufferが拡張される前提で書かれている処理があり, それが原因でpanicが発生していた.
新たに readAtLeast という関数を導入し, 期待するバッファーの状態を満たすようにした.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 6, 2022

Codecov Report

Merging #380 (79d8df0) into master (88aa13e) will increase coverage by 0.01%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master     #380      +/-   ##
==========================================
+ Coverage   79.94%   79.95%   +0.01%     
==========================================
  Files          52       52              
  Lines       17578    17582       +4     
==========================================
+ Hits        14053    14058       +5     
+ Misses       2957     2955       -2     
- Partials      568      569       +1     

Copy link
Copy Markdown
Owner

@goccy goccy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for great PR ! LGTM !

@goccy goccy merged commit a812201 into goccy:master Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic in decoder

3 participants