mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Safety fix for GetCharPointer
Uses IsValidNullTerminatedString from #19103 by Kethen
This commit is contained in:
1 parent
9d0c127961
commit
85f8fd0bdb
1 file changed
+10
-10
+10
-10
@@ -270,16 +270,6 @@ inline bool IsKernelAndNotVolatileAddress(const u32 address) {
|
||||
|
||||
bool IsScratchpadAddress(const u32 address);
|
||||
|
||||
// Used for auto-converted char * parameters, which can sometimes legitimately be null -
|
||||
// so we don't want to get caught in GetPointer's crash reporting.
|
||||
inline const char* GetCharPointer(const u32 address) {
|
||||
if (address) {
|
||||
return (const char *)GetPointer(address);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
inline const char *GetCharPointerUnchecked(const u32 address) {
|
||||
return (const char *)GetPointerUnchecked(address);
|
||||
}
|
||||
@@ -351,6 +341,16 @@ inline bool IsValidRange(const u32 address, const u32 size) {
|
||||
return ValidSize(address, size) == size;
|
||||
}
|
||||
|
||||
// Used for auto-converted char * parameters, which can sometimes legitimately be null -
|
||||
// so we don't want to get caught in GetPointer's crash reporting.
|
||||
inline const char *GetCharPointer(const u32 address) {
|
||||
if (address && IsValidNullTerminatedString(address)) {
|
||||
return GetCharPointerUnchecked(address);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Memory
|
||||
|
||||
// Avoiding a global include for NotifyMemInfo.
|
||||
|
||||
Reference in new issue
Block a user