!4369 Rectification of safety problems

Merge pull request !4369 from 韩靖/master
This commit is contained in:
openharmony_ci 2023-07-10 02:55:47 +00:00 committed by Gitee
commit 3545040542
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 21 additions and 21 deletions

View File

@ -134,7 +134,7 @@ public:
void VisitRegion(GateRegion* curRegion)
{
replacement_.SetState(curRegion->GetState());
currentIndex_ = curRegion->gateList_.size() - 1; // 1: -1 for size
currentIndex_ = static_cast<int32_t>(curRegion->gateList_.size() - 1); // 1: -1 for size
TryLoadDependStart(curRegion);
// 0: is state
for (; currentIndex_ > 0; currentIndex_--) {

View File

@ -452,8 +452,8 @@ int32_t DebuggerApi::GetRequestModuleIndex(const EcmaVM *ecmaVm, JSTaggedValue m
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required));
JSTaggedValue requireModule = requiredModule->GetEcmaModuleRecordName();
JSHandle<TaggedArray> requestedModules(thread, module->GetRequestedModules());
int32_t requestedModulesLen = static_cast<int32_t>(requestedModules->GetLength());
for (int32_t idx = 0; idx < requestedModulesLen; idx++) {
uint32_t requestedModulesLen = requestedModules->GetLength();
for (uint32_t idx = 0; idx < requestedModulesLen; idx++) {
JSTaggedValue requestModule = requestedModules->Get(idx);
if (JSTaggedValue::SameValue(requireModule, requestModule)) {
return idx;
@ -638,12 +638,12 @@ void DebuggerApi::GetImportVariables(const EcmaVM *ecmaVm, Local<ObjectRef> &mod
JSThread *thread = ecmaVm->GetJSThread();
JSHandle<TaggedArray> importArray(thread, TaggedArray::Cast(importEntries.GetTaggedObject()));
int32_t importEntriesLen = static_cast<int32_t>(importArray->GetLength());
uint32_t importEntriesLen = importArray->GetLength();
JSHandle<TaggedArray> environment(thread, TaggedArray::Cast(moduleEnvironment.GetTaggedObject()));
JSHandle<JSTaggedValue> starString = thread->GlobalConstants()->GetHandledStarString();
JSMutableHandle<ImportEntry> ee(thread, thread->GlobalConstants()->GetUndefined());
JSMutableHandle<JSTaggedValue> name(thread, thread->GlobalConstants()->GetUndefined());
for (int32_t idx = 0; idx < importEntriesLen; idx++) {
for (uint32_t idx = 0; idx < importEntriesLen; idx++) {
ee.Update(importArray->Get(idx));
JSTaggedValue key = ee->GetImportName();
JSTaggedValue localName = ee->GetLocalName();

View File

@ -788,10 +788,10 @@ void SamplesQueue::PostNapiFrame(CVector<FrameInfoTemp> &napiFrameInfoTemps,
{
os::memory::LockHolder holder(mtx_);
if (!IsFull()) {
int frameInfoTempsLength = static_cast<int>(napiFrameInfoTemps.size());
int frameStackLength = static_cast<int>(napiFrameStack.size());
size_t frameInfoTempsLength = napiFrameInfoTemps.size();
size_t frameStackLength = napiFrameStack.size();
// napiFrameInfoTemps
for (int i = 0; i < frameInfoTempsLength; i++) {
for (size_t i = 0; i < frameInfoTempsLength; i++) {
CheckAndCopy(frames_[rear_].frameInfoTemps[i].functionName,
sizeof(frames_[rear_].frameInfoTemps[i].functionName), napiFrameInfoTemps[i].functionName);
frames_[rear_].frameInfoTemps[i].columnNumber = napiFrameInfoTemps[i].columnNumber;
@ -804,7 +804,7 @@ void SamplesQueue::PostNapiFrame(CVector<FrameInfoTemp> &napiFrameInfoTemps,
frames_[rear_].frameInfoTemps[i].methodKey.state = napiFrameInfoTemps[i].methodKey.state;
}
// napiFrameStack
for (int i = 0; i < frameStackLength; i++) {
for (size_t i = 0; i < frameStackLength; i++) {
frames_[rear_].frameStack[i].methodIdentifier = napiFrameStack[i].methodIdentifier;
frames_[rear_].frameStack[i].state = napiFrameStack[i].state;
}

View File

@ -743,10 +743,10 @@ EcmaString *EcmaString::TrimBody(const JSThread *thread, const JSHandle<EcmaStri
{
uint32_t srcLen = src->GetLength();
int32_t start = 0;
int32_t end = srcLen - 1;
int32_t end = static_cast<int32_t>(srcLen) - 1;
if (mode == TrimMode::TRIM || mode == TrimMode::TRIM_START) {
start = base::StringHelper::GetStart(data, srcLen);
start = static_cast<int32_t>(base::StringHelper::GetStart(data, srcLen));
}
if (mode == TrimMode::TRIM || mode == TrimMode::TRIM_END) {
end = base::StringHelper::GetEnd(data, start, srcLen);

View File

@ -376,12 +376,12 @@ JSHandle<TaggedArray> JSAPIArrayList::GrowCapacity(const JSThread *thread, const
bool JSAPIArrayList::Has(const JSTaggedValue value) const
{
TaggedArray *elements = TaggedArray::Cast(GetElements().GetTaggedObject());
int32_t length = GetSize();
uint32_t length = GetSize();
if (length == 0) {
return false;
}
for (int32_t i = 0; i < length; i++) {
for (uint32_t i = 0; i < length; i++) {
if (JSTaggedValue::SameValue(elements->Get(i), value)) {
return true;
}

View File

@ -439,14 +439,14 @@ bool JSArray::IncludeInSortedValue(JSThread *thread, const JSHandle<JSTaggedValu
{
ASSERT(obj->IsJSArray());
JSHandle<JSArray> arrayObj = JSHandle<JSArray>::Cast(obj);
int32_t length = static_cast<int32_t>(arrayObj->GetArrayLength());
uint32_t length = arrayObj->GetArrayLength();
if (length == 0) {
return false;
}
int32_t left = 0;
int32_t right = length - 1;
uint32_t left = 0;
uint32_t right = length - 1;
while (left <= right) {
int32_t middle = (left + right) / 2;
uint32_t middle = (left + right) / 2;
JSHandle<JSTaggedValue> vv = JSArray::FastGetPropertyByValue(thread, obj, middle);
ComparisonResult res = JSTaggedValue::Compare(thread, vv, value);
if (res == ComparisonResult::EQUAL) {

View File

@ -360,7 +360,7 @@ public:
void IncreaseCount(int32_t inc)
{
count_ += inc;
count_ += static_cast<uint32_t>(inc);
}
void ClearCount()

View File

@ -80,7 +80,7 @@ MemMap FileMap(const char *fileName, int flag, int prot, int64_t offset)
return MemMap();
}
size_t size = static_cast<size_t>(lseek(fd, 0, SEEK_END));
off_t size = lseek(fd, 0, SEEK_END);
if (size <= 0) {
close(fd);
LOG_ECMA(ERROR) << fileName << " file is empty";

View File

@ -481,7 +481,7 @@ public:
return JSTaggedValue::Undefined();
}
};
static void ContainersVectorReplaceAllElementsFuzzTest(const uint8_t* data, size_t size)
{
if (size <= 0) {
@ -847,7 +847,7 @@ public:
JSNApi::DestroyJSVM(vm);
}
};
}
#endif