diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp index ba2960ca9f..a31e2a951c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.cpp @@ -100,6 +100,12 @@ s32 cellNetCtlGetInfo(s32 code, vm::ptr info) cellNetCtl.Error("cellNetCtlGetInfo(INFO_MTU): GetAdaptersAddresses buffer overflow."); free(pAddresses); pAddresses = (PIP_ADAPTER_ADDRESSES)malloc(bufLen); + + if (pAddresses == nullptr) + { + cellNetCtl.Error("cellNetCtlGetInfo(INFO_MTU): Unable to allocate memory for pAddresses."); + return CELL_NET_CTL_ERROR_NET_CABLE_NOT_CONNECTED; + } } ret = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &bufLen); @@ -182,6 +188,12 @@ s32 cellNetCtlGetInfo(s32 code, vm::ptr info) cellNetCtl.Error("cellNetCtlGetInfo(IP_ADDRESS): GetAdaptersAddresses buffer overflow."); free(pAdapterInfo); pAdapterInfo = (IP_ADAPTER_INFO*)malloc(bufLen); + + if (pAdapterInfo == nullptr) + { + cellNetCtl.Error("cellNetCtlGetInfo(IP_ADDRESS): Unable to allocate memory for pAddresses."); + return CELL_NET_CTL_ERROR_NET_CABLE_NOT_CONNECTED; + } } ret = GetAdaptersInfo(pAdapterInfo, &bufLen); @@ -251,6 +263,12 @@ s32 cellNetCtlGetInfo(s32 code, vm::ptr info) cellNetCtl.Error("cellNetCtlGetInfo(INFO_NETMASK): GetAdaptersAddresses buffer overflow."); free(pAdapterInfo); pAdapterInfo = (IP_ADAPTER_INFO*)malloc(bufLen); + + if (pAdapterInfo == nullptr) + { + cellNetCtl.Error("cellNetCtlGetInfo(INFO_NETMASK): Unable to allocate memory for pAddresses."); + return CELL_NET_CTL_ERROR_NET_CABLE_NOT_CONNECTED; + } } ret = GetAdaptersInfo(pAdapterInfo, &bufLen); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index 1abe4cc66a..c5bb50ec32 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -206,7 +206,7 @@ s32 cellSysCacheClear(void) { cellSysutil.Todo("cellSysCacheClear()"); - if (g_sysutil->cacheMounted.exchange(false)) + if (!g_sysutil->cacheMounted) { return CELL_SYSCACHE_ERROR_NOTMOUNTED; } @@ -214,7 +214,7 @@ s32 cellSysCacheClear(void) std::string localPath; Emu.GetVFS().GetDevice(std::string("/dev_hdd1/cache/"), localPath); - // TODO: Delete everything in the cache folder, except the README + // TODO: Write tests to figure out, what is deleted. return CELL_SYSCACHE_RET_OK_CLEARED; } @@ -229,6 +229,7 @@ s32 cellSysCacheMount(vm::ptr param) strncpy(param->getCachePath, ("/dev_hdd1/cache/" + std::string(id) + "/").c_str(), CELL_SYSCACHE_PATH_MAX); param->getCachePath[CELL_SYSCACHE_PATH_MAX - 1] = '\0'; Emu.GetVFS().CreateDir(std::string(param->getCachePath)); + g_sysutil->cacheMounted.exchange(true); return CELL_SYSCACHE_RET_OK_RELAYED; }