bneedhamia / sdconfigfile

Arduino Library to read an SD Configuration File
GNU Lesser General Public License v2.1
35 stars 19 forks source link

Sanity checks #15

Open pontacko opened 2 years ago

pontacko commented 2 years ago

Hello,

SDConfig.h:

uint8_t _valueIndex;     // position in _line[] where the value starts
            //  (or -1 if none)

unsigend integer 8-bit (0-255)

SDConfig.cpp: _valueIndex = -1; overflow to 255

if (_valueIndex < 0) { will never happen?!

regards & thanks for this project

bneedhamia commented 2 years ago

Ouch. Good catch. Because _valueIndex is an unsigned integer, it can never be less than zero. uint8_t range is 0..255.

I should change the code so that: 0 is the initial value of _valueIndex. A _valueIndex value of 0 after the line has ended indicates no = was in the line.