Skip to content

Fix hang on UTF-16 LE BOM file#636

Open
chrchr-github wants to merge 10 commits into
cppcheck-opensource:masterfrom
chrchr-github:chr_utf16
Open

Fix hang on UTF-16 LE BOM file#636
chrchr-github wants to merge 10 commits into
cppcheck-opensource:masterfrom
chrchr-github:chr_utf16

Conversation

@chrchr-github
Copy link
Copy Markdown
Contributor

@chrchr-github chrchr-github commented Mar 27, 2026

fixes #637

@chrchr-github chrchr-github changed the title Fix hang on UTF- 16 LE BOM file Fix hang on UTF-16 LE BOM file Mar 27, 2026
@firewave
Copy link
Copy Markdown
Collaborator

firewave commented Mar 27, 2026

Yeah - there's several places which lack checks for EOF. I have WIP tests for that and other corner cases/gaps somewhere - something to be done in preparation of #566.

@firewave
Copy link
Copy Markdown
Collaborator

With #647 it should be possible to write a test which uses the input in question.

@chrchr-github
Copy link
Copy Markdown
Contributor Author

With #647 it should be possible to write a test which uses the input in question.

Can we just run the tests with all three options?

@firewave
Copy link
Copy Markdown
Collaborator

Can we just run the tests with all three options?

Yes, if somebody adds the functionality. It didn't seem straight forward to me so I haven't yet. Feel free to do so.

@firewave
Copy link
Copy Markdown
Collaborator

I think I took a wrong turn. That should trigger with regular unit test. So please add a test for it.

@firewave
Copy link
Copy Markdown
Collaborator

I think I took a wrong turn. That should trigger with regular unit test. So please add a test for it.

Ah - you mentioned FileStream in the ticket. Still I think we should have a unit test (if missing).

@chrchr-github
Copy link
Copy Markdown
Contributor Author

So there is also some kind of platform divergence going on...

@chrchr-github
Copy link
Copy Markdown
Contributor Author

@chrchr-github
Copy link
Copy Markdown
Contributor Author

chrchr-github commented May 13, 2026

So there is also some kind of platform divergence going on...

Of course f.write("\xFF\xFE\x3B\x00") does something different on Linux, because why wouldn't it?

~$ hexdump pytest.cpp 
0000000 bfc3 bec3 003b                         
0000006

@chrchr-github chrchr-github marked this pull request as ready for review May 13, 2026 18:21
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.

Hang on UTF-16 with BOM

2 participants