Skip to content

json::parse on failed stream gets stuck #366

Closed

Description

@popizdeh

Creating a file stream for file that doesn't exist results in stream object whose fail() method returns true. json::parse never returns when called on such a stream. Adding a check for m_stream.fail() (in addition to eof()) in fill_line_buffer seems to do the trick, invalid_argument exception gets thrown. Not sure if this is the right fix, it might also make sense checking that stream isn't 'bad' (not sure what causes this to happen as bad() for missing file stream returns false).

Activity

  1. self-assigned this
    on Nov 23, 2016
  2. nlohmann commented on Nov 23, 2016

    @nlohmann
    Owner

    Thanks for reporting. I encountered the bug before, but never bothered to fix it... Commit 4bb41d0 adds a check in the lexer's constructor to immediately abort if the passed stream is fail()ed.

  3. added this to the Release 2.0.8 milestone on Nov 23, 2016
  4. nlohmann commented on Nov 24, 2016

    @nlohmann
    Owner

    @popizdeh Does this fix the issue?

  5. added
    state: please discuss
    on Nov 24, 2016
  6. popizdeh commented on Nov 25, 2016

    @popizdeh
    Author

    Haven't had the chance to try and won't be able in some time. I did have a look at your fix (and test) and it looks like it'll fix the issue so I'll close the bug. Thanks for the quick response.

  7. removed
    state: please discuss
    on Nov 25, 2016
  8. nlohmann commented on Nov 25, 2016

    @nlohmann
    Owner

    Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions