~fsx/protobluff

10730ca2c33875e17755c0c4956a682d5ea2cd79 — Frank Smit 11 months ago b903b67
Prevent heap-buffer-overflow error when ASAN is enabled.
1 files changed, 6 insertions(+), 1 deletions(-)

M src/core/varint.c
M src/core/varint.c => src/core/varint.c +6 -1
@@ 492,8 492,13 @@ pb_varint_scan(const uint8_t data[], size_t left) {
    0x00FF, 0x01FF, 0x03FF
  };

  // Prevent heap-buffer-overflow error when ASAN is enabled.
  // FIXME: Need to figure out if this is the right solution.
  const uint8_t tmp[16] = {0};
  memcpy((void *)tmp, (const void *)data, left);

  /* Load buffer into 128-bit integer and create high-bit mask */
  __m128i temp = _mm_loadu_si128((const __m128i *)data);
  __m128i temp = _mm_loadu_si128((const __m128i *)tmp);
  __m128i high = _mm_set1_epi8(0x80);

  /* Intersect and extract mask with high-bits set */