|
|
@@ -406,7 +406,7 @@ bool GpioHandler::readConfig()
|
|
|
bool httpEnabled = (toLower(splitted[5]) == "true");
|
|
|
char gpioName[100];
|
|
|
if (splitted.size() >= 7) {
|
|
|
- strcpy(gpioName, trim(splitted[6]).c_str());
|
|
|
+ strlcpy(gpioName, trim(splitted[6]).c_str(), sizeof(gpioName));
|
|
|
} else {
|
|
|
sprintf(gpioName, "GPIO%d", gpioNr);
|
|
|
}
|
|
|
@@ -724,10 +724,14 @@ gpio_int_type_t GpioHandler::resolveIntType(std::string input)
|
|
|
|
|
|
static GpioHandler *gpioHandler = NULL;
|
|
|
|
|
|
-void gpio_handler_create(httpd_handle_t server)
|
|
|
+void gpio_handler_create(httpd_handle_t server)
|
|
|
{
|
|
|
- if (gpioHandler == NULL)
|
|
|
- gpioHandler = new GpioHandler(CONFIG_FILE, server);
|
|
|
+ if (gpioHandler == NULL) {
|
|
|
+ gpioHandler = new (std::nothrow) GpioHandler(CONFIG_FILE, server);
|
|
|
+ if (gpioHandler == NULL) {
|
|
|
+ LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Unable to allocate GPIO handler");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void gpio_handler_init()
|