!664 fix code check, not involving logic. Work and data memory overflow modification

Merge pull request !664 from 石闽南/master
This commit is contained in:
openharmony_ci 2024-05-05 04:05:13 +00:00 committed by Gitee
commit 5e84199515
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 19 additions and 13 deletions

View File

@ -107,7 +107,7 @@ std::list<JSPtStepRange> SingleStepper::GetStepRanges(DebugInfoExtractor *extrac
}
std::unique_ptr<SingleStepper> SingleStepper::GetStepper(const EcmaVM *ecmaVm,
SingleStepper::Type type)
SingleStepper::Type type)
{
std::unique_ptr<PtMethod> ptMethod = DebuggerApi::GetMethod(ecmaVm);
ASSERT(ptMethod != nullptr);

View File

@ -63,6 +63,16 @@ bool ExecutePandaFile(panda::ecmascript::EcmaVM *vm,
return ret;
}
std::pair<std::string, std::string> GetNextPara()
{
std::string fileName = *g_iter;
std::string fileAbc = fileName.substr(fileName.find_last_of('/') + 1);
std::string entry = fileAbc.substr(0, fileAbc.size() - 4);
g_iter++;
g_runningCount++;
return {fileName, entry};
}
bool StartThread(uv_loop_t *loop)
{
uv_thread_t tid = 0;
@ -77,13 +87,8 @@ bool StartThread(uv_loop_t *loop)
g_mutex.Unlock();
break;
}
std::string fileName = *g_iter;
std::string fileAbc = fileName.substr(fileName.find_last_of('/') + 1);
std::string entry = fileAbc.substr(0, fileAbc.size() - 4);
g_iter++;
g_runningCount++;
auto [fileName, entry] = GetNextPara();
g_mutex.Unlock();
panda::ecmascript::EcmaVM *vm = panda::JSNApi::CreateEcmaVM(g_runtimeOptions);
if (vm == nullptr) {
std::cerr << "Cannot create vm." << std::endl;
@ -92,7 +97,6 @@ bool StartThread(uv_loop_t *loop)
panda::JSNApi::SetBundle(vm, !g_runtimeOptions.GetMergeAbc());
bool ret = ExecutePandaFile(vm, g_runtimeOptions, fileName, entry);
panda::JSNApi::DestroyJSVM(vm);
auto loop = static_cast<uv_loop_t *>(arg);
auto work = new uv_work_t;
std::string msg;
@ -104,6 +108,8 @@ bool StartThread(uv_loop_t *loop)
}
work->data = new char[msg.size() + 1];
if (strncpy_s(static_cast<char*>(work->data), msg.size() + 1, msg.data(), msg.size()) != EOK) {
delete static_cast<char*>(work->data);
delete work;
std::abort();
}
uv_queue_work(loop, work, [] (uv_work_t*) {}, [] (uv_work_t* work, int) {
@ -194,8 +200,9 @@ int Main(const int argc, const char **argv)
.count();
g_mutex.Lock();
const long long timeUnit = 1000'000'000;
std::cerr << "Run end, total file count: " << g_runningCount << ", used: "
<< ((endTime - startTime) / 1000'000'000) << "s." << std::endl;
<< ((endTime - startTime) / timeUnit) << "s." << std::endl;
g_mutex.Unlock();
return 0;
}

View File

@ -65,8 +65,7 @@ DispatchRequest::DispatchRequest(const std::string &message)
return;
}
std::string::size_type length = wholeMethod.length();
std::string::size_type indexPoint;
indexPoint = wholeMethod.find_first_of('.', 0);
std::string::size_type indexPoint = wholeMethod.find_first_of('.', 0);
if (indexPoint == std::string::npos || indexPoint == 0 || indexPoint == length - 1) {
code_ = RequestCode::METHOD_FORMAT_ERROR;
LOG_DEBUGGER(ERROR) << "method format error: " << wholeMethod;

View File

@ -91,8 +91,8 @@ std::string HttpResponse::DecodeStatus(const std::string& response, std::string:
auto statusStartPos = response.find_first_not_of(' ', versionEndPos);
if (statusStartPos != std::string::npos) {
auto statusEndPos = response.find(' ', statusStartPos);
if (statusEndPos != std::string::npos ||
(statusEndPos = response.find(EOL, statusStartPos)) != std::string::npos) {
statusEndPos = (statusEndPos == std::string::npos) ? response.find(EOL, statusStartPos) : statusEndPos;
if (statusEndPos != std::string::npos) {
return response.substr(statusStartPos, statusEndPos - statusStartPos);
}
}