mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Safety fix for GetCharPointer
Uses IsValidNullTerminatedString from #19103 by Kethen
This commit is contained in:
parent
9d0c127961
commit
85f8fd0bdb
1 changed files with 10 additions and 10 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue