File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
examples/ChunkRetryResponse Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -131,21 +131,34 @@ void setup() {
131
131
" /api" , HTTP_POST,
132
132
[](AsyncWebServerRequest *request) {
133
133
// request parsing has finished
134
+ String *data = (String *)request->_tempObject ;
135
+
136
+ if (!data) {
137
+ request->send (400 );
138
+ return ;
139
+ }
134
140
135
141
// no data ?
136
- if (!((String *)request->_tempObject )->length ()) {
142
+ if (!data->length ()) {
143
+ delete data;
144
+ request->_tempObject = nullptr ;
137
145
request->send (400 );
138
146
return ;
139
147
}
140
148
141
149
JsonDocument doc;
142
150
143
151
// deserialize and check for errors
144
- if (deserializeJson (doc, *(String *)request->_tempObject )) {
152
+ if (deserializeJson (doc, *data)) {
153
+ delete data;
154
+ request->_tempObject = nullptr ;
145
155
request->send (400 );
146
156
return ;
147
157
}
148
158
159
+ delete data;
160
+ request->_tempObject = nullptr ;
161
+
149
162
// start UART com: UART will send the data to the Serial console and wait for the key press
150
163
triggerUART = doc[" input" ].as <const char *>();
151
164
key = -1 ;
You can’t perform that action at this time.
0 commit comments