AWTRIX2.0-Controller
AWTRIX2.0-Controller copied to clipboard
Zero-size awtrix.json file may cause crash
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