GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fixed handling of incomplete UTF-8 BOM 0xefbbbf · cppcheck-opensource/simplecpp@5fb149d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • simplecpp.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎simplecpp.cpp‎

Copy file name to clipboardExpand all lines: simplecpp.cpp
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ class simplecpp::TokenList::Stream {
311311

312312
// The UTF-16 BOM is 0xfffe or 0xfeff.
313313
if (ch1 >= 0xfe) {
314-
const unsigned short bom = (static_cast<unsigned char>(get()) << 8);
314+
(void)get();
315+
const unsigned short bom = (static_cast<unsigned char>(ch1) << 8);
315316
if (peek() >= 0xfe)
316317
return bom | static_cast<unsigned char>(get());
317318
unget();
@@ -321,12 +322,15 @@ class simplecpp::TokenList::Stream {
321322
// Skip UTF-8 BOM 0xefbbbf
322323
if (ch1 == 0xef) {
323324
(void)get();
324-
if (get() == 0xbb && peek() == 0xbf) {
325+
if (peek() == 0xbb) {
325326
(void)get();
326-
} else {
327-
unget();
327+
if (peek() == 0xbf) {
328+
(void)get();
329+
return 0;
330+
}
328331
unget();
329332
}
333+
unget();
330334
}
331335

332336
return 0;

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.