Skip to content

Commit a0d7f43

Browse files
committed
Fix stack size detection on Linux (fix #1427)
1 parent 9462906 commit a0d7f43

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Diff for: ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Increase jslMatch error buffer size to handle "UNFINISHED TEMPLATE LITERAL" string (#1426)
22
nRF5x: Make FlashWrite cope with flash writes > 4k
33
Increase max size of native strings on platforms that support it - 16 bit to 32 bit (#1432)
4+
Fix stack size detection on Linux (fix #1427)
45

56
1v98 : Allow Crypto SHA1 without SHA256/512 (for ESP8266 where flash is scarce)
67
Add better docs for the form of Wifi callback functions

Diff for: src/jsutils.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,9 @@ size_t jsuGetFreeStack() {
844844
char ptr; // this is on the stack
845845
extern void *STACK_BASE;
846846
uint32_t count = (uint32_t)((size_t)STACK_BASE - (size_t)&ptr);
847-
return 1000000 - count; // give it 1 megabyte of stack
847+
const uint32_t max_stack = 1000000; // give it 1 megabyte of stack
848+
if (count>max_stack) return 0;
849+
return max_stack - count;
848850
#else
849851
// stack depth seems pretty platform-specific :( Default to a value that disables it
850852
return 1000000; // no stack depth check on this platform

0 commit comments

Comments
 (0)