ubj
ubj copied to clipboard
Two bugs: size_t >=0 and empty array/objects
Two bugs found:
- There is a size_t comparison >= 0 of constant, which always evaluates to TRUE as size_t is unsigned
- The size of an Array/Object can be zero, need to determine if size has been read
Notes on # 2:
I was testing the compatibility between this library and another converter and the converter wrote an empty array as: '[' '#' 'i' '0'
Unfortunately, this ubjson parser was using the zero size to determine whether or not to read the closing array marker ']'. This caused a stack overflow on some files and infinite recursion on others...
I have suggested to the other library to write empty arrays as '[' ']', however, it is not technically wrong to have a zero sized container, as per spec: