mcmtroffaes / inipp

Simple C++ ini parser.
MIT License
282 stars 53 forks source link

Fix PVS warnings #5

Closed MikailBag closed 5 years ago

MikailBag commented 5 years ago

This pull request fixes problems, detected by PVS-Studio static analyzer. I'm not expert in C++, but it really seems to me that current implementation will enter endless loop if reading from is fails.

Analyzer output before changes:

.../inipp.h:127:1: error: V663 Infinite loop is possible. The 'cin.eof()' condition is insufficient to break from the loop. Consider adding the 'cin.fail()' function call to the conditional expression.
.../inipp.h:127:1: warning: V1024 The 'is' stream is checked for EOF before reading from it, but is not checked after reading. Potential use of invalid data.
mcmtroffaes commented 5 years ago

Thanks, Mikail. I've pushed an alternative and simpler patch which should also resolve the issue, and which passes the regression tests.