mirror of
https://github.com/esphome/esphome.git
synced 2025-10-07 12:23:47 +01:00
fix dangling pointer
This commit is contained in:
@@ -206,7 +206,7 @@ void AsyncWebServerRequest::redirect(const std::string &url) {
|
||||
|
||||
void AsyncWebServerRequest::init_response_(AsyncWebServerResponse *rsp, int code, const char *content_type) {
|
||||
// Set status code - use constants for common codes to avoid string allocation
|
||||
const char *status;
|
||||
const char *status = nullptr;
|
||||
switch (code) {
|
||||
case 200:
|
||||
status = HTTPD_200;
|
||||
@@ -218,10 +218,9 @@ void AsyncWebServerRequest::init_response_(AsyncWebServerResponse *rsp, int code
|
||||
status = HTTPD_409;
|
||||
break;
|
||||
default:
|
||||
status = to_string(code).c_str();
|
||||
break;
|
||||
}
|
||||
httpd_resp_set_status(*this, status);
|
||||
httpd_resp_set_status(*this, status == nullptr ? to_string(code).c_str() : status);
|
||||
|
||||
if (content_type && *content_type) {
|
||||
httpd_resp_set_type(*this, content_type);
|
||||
|
Reference in New Issue
Block a user