AWTRIX2.0-Controller icon indicating copy to clipboard operation
AWTRIX2.0-Controller copied to clipboard

Zero-size awtrix.json file may cause crash

Open avanx opened this issue 3 years ago • 0 comments

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

avanx avatar Sep 12 '21 03:09 avanx