Skip to content

Commit 54f397a

Browse files
committed
Prevent spaceAvailable from possibly going negative
1 parent c5253f5 commit 54f397a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Firmware/RTK_Everywhere/Tasks.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,8 @@ void processUart1Message(SEMP_PARSE_STATE *parse, uint16_t type)
835835
if (appleAccessory->latestEASessionDataIsBlocking() == false)
836836
{
837837
size_t spaceAvailable = latestEASessionDataMaxLen - strlen(latestEASessionData);
838-
spaceAvailable -= 3; // Leave room for the CR, LF and NULL
838+
if (spaceAvailable >= 3)
839+
spaceAvailable -= 3; // Leave room for the CR, LF and NULL
839840
while (spaceAvailable < parse->length) // If the buffer is full, delete the oldest message(s)
840841
{
841842
const char *lfPtr = strstr(latestEASessionData, "\n"); // Find the first LF

0 commit comments

Comments
 (0)