Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #354
Closed
Open
Issue created Sep 16, 2016 by Administrator@rootContributor

Prettyfier uses undefined behaviour to sequence writes

Created by: Dwergi

The entirety of Prettyfier uses this pattern:

 size_t writeBlockClose(uint8_t c) {    
      return unindentIfNeeded() + _sink.write( c );    
 }

This makes an assumption that unindentIfNeeded is called first, but this assumption is wrong, because + is not a sequence point. C++ makes no guarantees about evaluation order in this case, and in VS2015, _sink.write is called first.

To guarantee order of evaluation, all of these functions should be split across two lines:

  size_t writeBlockClose(uint8_t c) {
    size_t written = unindentIfNeeded();
    return written + _sink.write( c );
  }
Assignee
Assign to
Time tracking