ubj icon indicating copy to clipboard operation
ubj copied to clipboard

Two bugs: size_t >=0 and empty array/objects

Open jpoag opened this issue 9 years ago • 0 comments

Two bugs found:

  1. There is a size_t comparison >= 0 of constant, which always evaluates to TRUE as size_t is unsigned
  2. 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:

A count must be >= 0.

jpoag avatar Nov 01 '16 17:11 jpoag