-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serializeMsgPack to dinamically allocated buffer of size len falls short. #1545
Comments
Hi @gnalbandian, Thank you very much for reporting this issue 👍 Indeed, I just realized that, like I'll fix this problem soon; meanwhile, increase the size of the allocated buffer by 1 byte (to make room for the terminator) and continue passing Best Regards, |
Hi @bblanchon. As usuall, I appreciate your answer.
Wouldn't measureMsgPack(jsonDoc) already consider the null-terminator in its answer? |
Yes, that's what I meant. |
Fix published in ArduinoJson 6.18.0 |
Great! Thanks @bblanchon. |
Hi @bblanchon.
I am extensively using your library along with ESPASyncWebServer from @me-no-dev.
Once a second I send to webSocket clients a stream of ~400bytes with data to update a web page data.
I am using a DynamicJsonBuffer to store all my data.
After successful buffer allocation and population, I send the data and free the buffer.
When reading the received data, I found out one value is missing. MessagePack is correctly decoded by javascript client, and it parses fine as a json. It's just the value of a key that instead of showing its current value, it shows always 0. It's data type is int32_t
After many test i found that increasing by 1 the length of the buffer size, I receive all the data as it should. ie:
serializeMsgPack(jsonDoc, buffer, len + 1); // **<- the issue relies here**
The following section has not been modified:
ws.binaryAll(buffer, len);
Never added +1Unfortunately, applying this 'fix' leads to random crash, very likely because of buffer overflow, not sure thou.
Can yo shed some light over here. Thanks @bblanchon
The text was updated successfully, but these errors were encountered: