add some nullptr assert and free/close space/fd

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAJUVD
Signed-off-by: linxiang8 <linxiang8@huawei.com>
Change-Id: I977bc6e18b3da215808d531adb58f82229ff7908
This commit is contained in:
linxiang8 2024-08-12 10:37:51 +08:00
parent 47e7002658
commit 9849e792fc
5 changed files with 9 additions and 3 deletions

View File

@ -1079,7 +1079,7 @@ public:
if (index >= bb.succs.size()) {
if (bb.loopNumber > 0) {
if (visitState_[curState.bbId] == MarkState::ON_STACK) {
ASSERT(loopInfo->loopHeadId == curState.bbId);
ASSERT(loopInfo != nullptr && loopInfo->loopHeadId == curState.bbId);
loopInfo = loopInfo->parentInfo;
visitState_[curState.bbId] = MarkState::VISITED1;
}

View File

@ -268,6 +268,7 @@ void HeapSnapshotJSONSerializer::SerializeStringTable(HeapSnapshot *snapshot, St
void HeapSnapshotJSONSerializer::SerializeString(CString *str, StreamWriter *writer)
{
ASSERT(str != nullptr);
const char *s = str->c_str();
while (*s != '\0') {
if (*s == '\"' || *s == '\\') {

View File

@ -58,7 +58,6 @@ bool JsStackGetter::ParseMethodInfo(struct MethodKey &methodKey,
bool isCpuProfiler)
{
auto method = it.CheckAndGetMethod();
const JSPandaFile *jsPandaFile = method->GetJSPandaFile();
codeEntry.methodKey = methodKey;
if (method->IsNativeWithCallField()) {
FrameIterator itNext(it.GetSp(), it.GetThread());
@ -66,6 +65,10 @@ bool JsStackGetter::ParseMethodInfo(struct MethodKey &methodKey,
GetNativeMethodCallPos(itNext, codeEntry);
GetNativeStack(vm, it, codeEntry.functionName, sizeof(codeEntry.functionName), isCpuProfiler);
} else {
const JSPandaFile *jsPandaFile = method->GetJSPandaFile();
if (jsPandaFile == nullptr) {
return false;
}
EntityId methodId = reinterpret_cast<MethodLiteral *>(methodKey.methodIdentifier)->GetMethodId();
// function name
const char *functionName = MethodLiteral::GetMethodName(jsPandaFile, methodId, true);

View File

@ -164,6 +164,7 @@ const JSPandaFile* FrameHandler::GetJSPandaFile() const
std::string FrameHandler::GetFileName() const
{
auto pandaFile = GetJSPandaFile();
ASSERT(pandaFile != nullptr);
return pandaFile->GetJSPandaFileDesc().c_str();
}

View File

@ -164,6 +164,7 @@ public:
if (GetIsEncryptedBundle() > 0) {
DecryptRemoveKey(fd);
}
close(fd);
#endif
return true;
}
@ -469,4 +470,4 @@ private:
bool IsEncryptedBundle_{false};
};
} // namespace panda::ecmascript::kungfu
#endif
#endif