From c8517ee5b689926ddbddc2236d87ee68f48b8c73 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Wed, 12 Jul 2023 11:54:20 +0200 Subject: [PATCH] Fix double call to `size()` in `serializeMsgPack()` Ported from afbcc2106e404231bc0cfedb615b7674e2ae8c9c --- CHANGELOG.md | 1 + src/ArduinoJson/MsgPack/MsgPackSerializer.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06661a37..a6b71ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,3 +16,4 @@ HEAD * Always store `serialized("string")` by copy (#1915) * Remove the zero-copy mode of `deserializeJson()` and `deserializeMsgPack()` * Fix double lookup in `to()` +* Fix double call to `size()` in `serializeMsgPack()` \ No newline at end of file diff --git a/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp b/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp index 0b727ee8..374d3172 100644 --- a/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp +++ b/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp @@ -47,7 +47,7 @@ class MsgPackSerializer : public Visitor { size_t visitArray(const ArrayData& array) { size_t n = array.size(); if (n < 0x10) { - writeByte(uint8_t(0x90 + array.size())); + writeByte(uint8_t(0x90 + n)); } else if (n < 0x10000) { writeByte(0xDC); writeInteger(uint16_t(n));