Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Zero-size awtrix.json file may cause crash #44

Open
avanx opened this issue Sep 12, 2021 · 0 comments
Open

Zero-size awtrix.json file may cause crash #44

avanx opened this issue Sep 12, 2021 · 0 comments

Comments

@avanx
Copy link

avanx commented Sep 12, 2021

platform = [email protected]

module = ESP-12F

In setup() function

File configFile = LittleFS.open("/awtrix.json", "r");
if (configFile)
{
    size_t size = configFile.size();
    // Allocate a buffer to store contents of the file.
    std::unique_ptr<char[]> buf(new char[size]);
    configFile.readBytes(buf.get(), size);
    DynamicJsonBuffer jsonBuffer;
    JsonObject &json = jsonBuffer.parseObject(buf.get());
    if (json.success())

If /awtrix.json is newly add, its size will be zero.Then buf will be buf(new char[0]).
In fuction jsonBuffer.parseObject(buf.get());, it will read address 0x0, causes Exception (28) crash

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant