Check values of getenv() for validity

Signed-off-by: Ryan Choi <ryan.h.choi@gmail.com>
This commit is contained in:
Ryan Hyun Choi 2020-07-27 14:21:52 +09:00 committed by Hyukwoo Park
commit 99b2d0f8ce
4 changed files with 11 additions and 5 deletions

View file

@ -2277,7 +2277,8 @@ NEVER_INLINE Value ByteCodeInterpreter::tryOperation(ExecutionState*& state, siz
newState->context()->vmInstance()->currentSandBox()->fillStackDataIntoErrorObject(val);
#ifndef NDEBUG
if (getenv("DUMP_ERROR_IN_TRY_CATCH") && strlen(getenv("DUMP_ERROR_IN_TRY_CATCH"))) {
char* dumpErrorInTryCatch = getenv("DUMP_ERROR_IN_TRY_CATCH");
if (dumpErrorInTryCatch && (strcmp(dumpErrorInTryCatch, "1") == 0)) {
ErrorObject::StackTraceData* data = ErrorObject::StackTraceData::create(newState->context()->vmInstance()->currentSandBox());
StringBuilder builder;
builder.appendString("Caught error in try-catch block\n");