-
Notifications
You must be signed in to change notification settings - Fork 845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Small bug fixes and cleanups from fuzz testing #3299
Small bug fixes and cleanups from fuzz testing #3299
Conversation
switch to acceptSpaces by default
@@ -145,28 +145,56 @@ inline boost::uint32_t readPackedIntFromStream(std::stringstream &ss) { | |||
int shift, offset; | |||
char tmp; | |||
ss.read(&tmp, sizeof(tmp)); | |||
if (ss.fail()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could roll this into an ss_check inline function. We might want to check for premature eof as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but a premature EOF in the middle of reading the char here should result in the failbit being set (since the requested number of bytes wasn't read), so that case is covered. And if we hit EOF after reading the bytes we don't care (at least not here).
Except for the comment, all looks good. |
This PR includes a number of small fixes and changes to problems that showed up during the fuzz testing:
toInt()
andtoDouble()
functions used during the MOL file parsing now generate errors if the input strings contain characters that cannot appear in numbers. This is necessary because bothstrtol
andatof
happily return zero if they fail. Switching toboost::lexical_cast
would be less code, but it is significantly slower. The changes here do not noticeably impact the speed of the code (I benchmarked mol file parsing to be sure of this)M MRV SMA
is now stricter. We may want to consider extending this strictness to other CTAB tags.makeAHAtomQuery()
was incorrectly returning anATOM_EQUALS_QUERY *
. That query is anATOM_NULL_QUERY
, which is different.StreamOps.h
now explicitly throw anstd::runtime_error()
if they fail to read the required data from the stream.