Fix potential array out of bounds issue

Issue:  #IB5M9I
Signed-off-by: yanzhiqi1 <yanzhiqi1@huawei.com>
This commit is contained in:
yanzhiqi1 2024-11-20 10:01:18 +08:00
parent 0095d534b3
commit 7d3eb85db2

View File

@ -21,8 +21,7 @@
#include "ecmascript/mem/mem.h"
namespace panda::ecmascript {
static const int MAX_STACK_SIZE = 256;
static const int FRAMES_LEN = 16;
static const int MAX_STACK_SIZE = 16;
void Backtrace(std::ostringstream &stack, [[maybe_unused]] bool enableCache)
{
@ -35,7 +34,7 @@ void Backtrace(std::ostringstream &stack, [[maybe_unused]] bool enableCache)
}
stack << "=====================Backtrace========================";
for (int i = 0; i < FRAMES_LEN; ++i) {
for (int i = 0; i < framesLen; ++i) {
if (stackList[i] == nullptr) {
break;
}