File tree Expand file tree Collapse file tree
examples/ChunkRetryResponse Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -131,21 +131,34 @@ void setup() {
131131 " /api" , HTTP_POST,
132132 [](AsyncWebServerRequest *request) {
133133 // request parsing has finished
134+ String *data = (String *)request->_tempObject ;
135+
136+ if (!data) {
137+ request->send (400 );
138+ return ;
139+ }
134140
135141 // no data ?
136- if (!((String *)request->_tempObject )->length ()) {
142+ if (!data->length ()) {
143+ delete data;
144+ request->_tempObject = nullptr ;
137145 request->send (400 );
138146 return ;
139147 }
140148
141149 JsonDocument doc;
142150
143151 // deserialize and check for errors
144- if (deserializeJson (doc, *(String *)request->_tempObject )) {
152+ if (deserializeJson (doc, *data)) {
153+ delete data;
154+ request->_tempObject = nullptr ;
145155 request->send (400 );
146156 return ;
147157 }
148158
159+ delete data;
160+ request->_tempObject = nullptr ;
161+
149162 // start UART com: UART will send the data to the Serial console and wait for the key press
150163 triggerUART = doc[" input" ].as <const char *>();
151164 key = -1 ;
You can’t perform that action at this time.
0 commit comments