Skip to content

Commit

Permalink
Merge pull request #18797 from hrydgard/more-fixes
Browse files Browse the repository at this point in the history
Fix some really obscure crashes
  • Loading branch information
hrydgard authored Jan 30, 2024
2 parents cfadc39 + fae1f4a commit d7a250d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
20 changes: 11 additions & 9 deletions Core/ELF/ElfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,17 +533,19 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop)
u32 srcSize = p->p_filesz;
u32 dstSize = p->p_memsz;
u8 *dst = Memory::GetPointerWriteRange(writeAddr, dstSize);
if (dst) {
if (srcSize < dstSize) {
memset(dst + srcSize, 0, dstSize - srcSize); //zero out bss
NotifyMemInfo(MemBlockFlags::WRITE, writeAddr + srcSize, dstSize - srcSize, "ELFZero");
}

if (srcSize < dstSize)
{
memset(dst + srcSize, 0, dstSize - srcSize); //zero out bss
NotifyMemInfo(MemBlockFlags::WRITE, writeAddr + srcSize, dstSize - srcSize, "ELFZero");
memcpy(dst, src, srcSize);
std::string tag = StringFromFormat("ELFLoad/%08x", writeAddr);
NotifyMemInfo(MemBlockFlags::WRITE, writeAddr, srcSize, tag.c_str(), tag.size());
DEBUG_LOG(LOADER, "Loadable Segment Copied to %08x, size %08x", writeAddr, (u32)p->p_memsz);
} else {
ERROR_LOG(LOADER, "Bad ELF segment. Trying to write %d bytes to %08x", dstSize, writeAddr);
}

memcpy(dst, src, srcSize);
std::string tag = StringFromFormat("ELFLoad/%08x", writeAddr);
NotifyMemInfo(MemBlockFlags::WRITE, writeAddr, srcSize, tag.c_str(), tag.size());
DEBUG_LOG(LOADER,"Loadable Segment Copied to %08x, size %08x", writeAddr, (u32)p->p_memsz);
}
}
memblock.ListBlocks();
Expand Down
10 changes: 5 additions & 5 deletions Core/HW/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ void DisplayFireVblankStart() {
}

void DisplayFireVblankEnd() {
std::vector<VblankCallback> toCall = [] {
std::lock_guard<std::mutex> guard(listenersLock);
return vblankListeners;
}();

isVblank = 0;
std::vector<VblankCallback> toCall;
{
std::lock_guard<std::mutex> guard(listenersLock);
toCall = vblankListeners;
}

for (VblankCallback cb : toCall) {
cb();
Expand Down
8 changes: 6 additions & 2 deletions UI/GameScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ void GameScreen::update() {
CRC32string = int2hexstr(crcvalue);
tvCRC_->SetVisibility(UI::V_VISIBLE);
tvCRC_->SetText(CRC32string);
btnCalcCRC_->SetVisibility(UI::V_GONE);
if (btnCalcCRC_) {
btnCalcCRC_->SetVisibility(UI::V_GONE);
}
}
}
}
Expand Down Expand Up @@ -433,7 +435,9 @@ UI::EventReturn GameScreen::OnCwCheat(UI::EventParams &e) {
UI::EventReturn GameScreen::OnDoCRC32(UI::EventParams& e) {
CRC32string = "...";
Reporting::QueueCRC(gamePath_);
btnCalcCRC_->SetEnabled(false);
if (btnCalcCRC_) {
btnCalcCRC_->SetEnabled(false);
}
return UI::EVENT_DONE;
}

Expand Down
6 changes: 3 additions & 3 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,11 +1217,11 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
systemSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.sNickName, sy->T("Change Nickname"), "", 32, screenManager()));
systemSettings->Add(new CheckBox(&g_Config.bDayLightSavings, sy->T("Day Light Saving")));
static const char *dateFormat[] = { "YYYYMMDD", "MMDDYYYY", "DDMMYYYY" };
systemSettings->Add(new PopupMultiChoice(&g_Config.iDateFormat, sy->T("Date Format"), dateFormat, 0, 3, I18NCat::SYSTEM, screenManager()));
systemSettings->Add(new PopupMultiChoice(&g_Config.iDateFormat, sy->T("Date Format"), dateFormat, 0, ARRAY_SIZE(dateFormat), I18NCat::SYSTEM, screenManager()));
static const char *timeFormat[] = { "24HR", "12HR" };
systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, sy->T("Time Format"), timeFormat, 0, 2, I18NCat::SYSTEM, screenManager()));
systemSettings->Add(new PopupMultiChoice(&g_Config.iTimeFormat, sy->T("Time Format"), timeFormat, 0, ARRAY_SIZE(timeFormat), I18NCat::SYSTEM, screenManager()));
static const char *buttonPref[] = { "Use O to confirm", "Use X to confirm" };
systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, sy->T("Confirmation Button"), buttonPref, 0, 2, I18NCat::SYSTEM, screenManager()));
systemSettings->Add(new PopupMultiChoice(&g_Config.iButtonPreference, sy->T("Confirmation Button"), buttonPref, 0, ARRAY_SIZE(buttonPref), I18NCat::SYSTEM, screenManager()));

systemSettings->Add(new ItemHeader(sy->T("Recording")));
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(MOBILE_DEVICE))
Expand Down

0 comments on commit d7a250d

Please sign in to comment.