mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-25 18:46:55 +01:00
Logging: Prevent crash for nullptr strings
This commit is contained in:
parent
fa8bab2f39
commit
3e467e220e
@ -140,6 +140,17 @@ static std::tuple<Args...> cafeExportBuildArgTuple(PPCInterpreter_t* hCPU, R(fn)
|
|||||||
return std::tuple<Args...>{ cafeExportGetParamWrapper<Args>(hCPU, gprIndex, fprIndex)... };
|
return std::tuple<Args...>{ cafeExportGetParamWrapper<Args>(hCPU, gprIndex, fprIndex)... };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T cafeExportGetFormatParamWrapper(PPCInterpreter_t* hCPU, int& gprIndex, int& fprIndex)
|
||||||
|
{
|
||||||
|
T v;
|
||||||
|
cafeExportParamWrapper::getParamWrapper(hCPU, gprIndex, fprIndex, v);
|
||||||
|
// if T is char* or const char*, return "null" instead of nullptr since newer fmtlib would throw otherwise
|
||||||
|
if constexpr (std::is_same_v<T, char*> || std::is_same_v<T, const char*>)
|
||||||
|
return v ? v : (T)"null";
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using _CAFE_FORMAT_ARG = std::conditional_t<std::is_pointer_v<T>,
|
using _CAFE_FORMAT_ARG = std::conditional_t<std::is_pointer_v<T>,
|
||||||
std::conditional_t<std::is_same_v<T, char*> || std::is_same_v<T, const char*>, T, MEMPTR<T>>, T>;
|
std::conditional_t<std::is_same_v<T, char*> || std::is_same_v<T, const char*>, T, MEMPTR<T>>, T>;
|
||||||
@ -150,7 +161,7 @@ static auto cafeExportBuildFormatTuple(PPCInterpreter_t* hCPU, R(fn)(Args...))
|
|||||||
int gprIndex = 0;
|
int gprIndex = 0;
|
||||||
int fprIndex = 0;
|
int fprIndex = 0;
|
||||||
return std::tuple<_CAFE_FORMAT_ARG<Args>...>{
|
return std::tuple<_CAFE_FORMAT_ARG<Args>...>{
|
||||||
cafeExportGetParamWrapper<_CAFE_FORMAT_ARG<Args>>(hCPU, gprIndex, fprIndex)...
|
cafeExportGetFormatParamWrapper<_CAFE_FORMAT_ARG<Args>>(hCPU, gprIndex, fprIndex)...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user