Skip to content

Commit ee4e249

Browse files
committed
Add implementation for VerifyStackOK
1 parent ec17b1f commit ee4e249

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/CLR/Core/Checks.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,21 @@
99

1010
HRESULT CLR_Checks::VerifyStackOK(const CLR_RT_StackFrame &stack, const CLR_RT_HeapBlock *top, const int num)
1111
{
12-
(void)stack;
13-
(void)top;
14-
(void)num;
12+
NANOCLR_HEADER();
13+
14+
// Check if stack has enough space for num elements
15+
if (top + num > stack.m_evalStackEnd)
16+
{
17+
NANOCLR_SET_AND_LEAVE(CLR_E_STACK_OVERFLOW);
18+
}
1519

16-
return S_OK;
20+
// Check if top is within stack bounds
21+
if (top < stack.m_evalStack || top >= stack.m_evalStackEnd)
22+
{
23+
NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
24+
}
25+
26+
NANOCLR_NOCLEANUP();
1727
}
1828

1929
HRESULT CLR_Checks::VerifyObject(CLR_RT_HeapBlock &top)

0 commit comments

Comments
 (0)