Skip to content

Commit 8c43a18

Browse files
author
Liyou Zhou
committed
Add guard against overfolw
1 parent 51f0c44 commit 8c43a18

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/mbed_platform.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ namespace test {
5151
}
5252

5353
uint32_t inc_sleep_until_buf_tail(void) {
54-
return ++sleep_until_buf_tail;
54+
if (sleep_until_buf_tail < BUFFER_SIZE-1) {
55+
return ++sleep_until_buf_tail;
56+
} else {
57+
return -1;
58+
}
5559
}
5660
#endif
5761
}; // namespace test

0 commit comments

Comments
 (0)