This repository has been archived on 2026-09-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
golem-v1-tinycbor/tests
Thiago Macieira 2421690d44 Fix #137: off-by-one error in UTF-8 decoding
I ported this from code I had written for Qt, where the subtraction was
correct. Qt's code is roughly:

    uchar b = *src++;
    ...
    int bytesAvailable = Traits::availableBytes(src, end);
    if (Q_UNLIKELY(bytesAvailable < charsNeeded - 1)) {

Which means src was advanced by the time we call Traits::availableBytes,
meaning that call returns the number of continuation bytes only. Our
code was:

    ptrdiff_t n = end - *buffer;
    ...
    uc = *(*buffer)++;
    ...
    if (n < charsNeeded - 1)

Which means our n is the total number of bytes, including the first
byte.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
2018-09-21 09:41:57 -07:00
..
2018-02-05 18:02:52 -08:00
2018-02-05 18:02:52 -08:00
2016-10-07 15:13:31 +02:00
2018-07-08 11:16:12 -07:00