Skip to content

Commit

Permalink
Some cleanups and fixes to obscure crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 24, 2023
1 parent 559cc60 commit 6705c79
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Common/Net/HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ namespace http {

// TODO: do something sane here
constexpr const char *DEFAULT_USERAGENT = "PPSSPP";
constexpr const char *HTTP_VERSION = "1.1";

Client::Client() {
httpVersion_ = "1.1";
userAgent_ = DEFAULT_USERAGENT;
}

Expand Down Expand Up @@ -353,7 +353,7 @@ int Client::SendRequestWithData(const char *method, const RequestParams &req, co
"\r\n";

buffer.Printf(tpl,
method, req.resource.c_str(), httpVersion_,
method, req.resource.c_str(), HTTP_VERSION,
host_.c_str(),
userAgent_.c_str(),
req.acceptMime,
Expand Down
1 change: 0 additions & 1 deletion Common/Net/HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class Client : public net::Connection {

protected:
std::string userAgent_;
const char *httpVersion_;
double dataTimeout_ = 900.0;
};

Expand Down
7 changes: 5 additions & 2 deletions Common/UI/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ void ScreenManager::getFocusPosition(float &x, float &y, float &z) {
}

void ScreenManager::sendMessage(const char *msg, const char *value) {
if (!strcmp(msg, "recreateviews"))
if (!msg) {
_dbg_assert_(false, "Empty msg in ScreenManager::sendMessage");
} else if (!strcmp(msg, "recreateviews")) {
RecreateAllViews();
if (!strcmp(msg, "lost_focus")) {
} else if (!strcmp(msg, "lost_focus")) {
TouchInput input{};
input.x = -50000.0f;
input.y = -50000.0f;
Expand All @@ -238,6 +240,7 @@ void ScreenManager::sendMessage(const char *msg, const char *value) {
input.id = 0;
touch(input);
}

if (!stack_.empty())
stack_.back().screen->sendMessage(msg, value);
}
Expand Down
3 changes: 1 addition & 2 deletions Core/FileSystems/BlockDevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ NPDRMDemoBlockDevice::NPDRMDemoBlockDevice(FileLoader *fileLoader)

fileLoader_->ReadAt(0x24, 1, 4, &psarOffset);
size_t readSize = fileLoader_->ReadAt(psarOffset, 1, 256, &np_header);
if(readSize!=256){
if (readSize != 256){
ERROR_LOG(LOADER, "Invalid NPUMDIMG header!");
}

Expand Down Expand Up @@ -445,7 +445,6 @@ NPDRMDemoBlockDevice::NPDRMDemoBlockDevice(FileLoader *fileLoader)
}

currentBlock = -1;

}

NPDRMDemoBlockDevice::~NPDRMDemoBlockDevice()
Expand Down
6 changes: 6 additions & 0 deletions Core/HLE/sceIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,12 @@ static u32 sceIoLseek32Async(int id, int offset, int whence) {
}

static FileNode *__IoOpen(int &error, const char *filename, int flags, int mode) {
if (!filename) {
// To prevent crashes. Not sure about the correct value.
error = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;
return nullptr;
}

int access = FILEACCESS_NONE;
if (flags & PSP_O_RDONLY)
access |= FILEACCESS_READ;
Expand Down

0 comments on commit 6705c79

Please sign in to comment.