Skip to content

Commit dc2344b

Browse files
committed
Change recursive callback to vrecv with a goto call to halt massive stack space utilization.
1 parent 269f145 commit dc2344b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ATParser.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ bool ATParser::vsend(const char *command, va_list args)
190190

191191
bool ATParser::vrecv(const char *response, va_list args)
192192
{
193+
vrecv_start:
193194
// Iterate through each line in the expected response
194195
while (response[0]) {
195196
// Since response is const, we need to copy it into our buffer to
@@ -245,8 +246,10 @@ bool ATParser::vrecv(const char *response, va_list args)
245246
_oobs[k].cb();
246247

247248
// oob may have corrupted non-reentrant buffer,
248-
// so we need to set it up again
249-
return vrecv(response, args);
249+
// so we need to set it up again.
250+
// Use goto to save stack usage rather than a
251+
// recursive approach.
252+
goto vrecv_start;
250253
}
251254
}
252255

0 commit comments

Comments
 (0)