mirror of https://github.com/PCSX2/pcsx2.git
pcsx2 64b: fix crash on string formating function
Call to vsnprintf update the gp_offset of the varargs (at least on x86_64 linux). Therefore the 2nd call (because buffer was too small) uses out-of-memory arguments We need to keep a local copy otherwise you will get an awful SIGSEV Note: I'm sure we have same issue on plugins
This commit is contained in:
parent
90d27bf5f6
commit
aba0a09816
|
@ -153,10 +153,14 @@ static GlobalBufferManager< BaseTlsVariable< FastFormatBuffers > > m_buffer_tls(
|
|||
//static __ri void format_that_ascii_mess( SafeArray<char>& buffer, uint writepos, const char* fmt, va_list argptr )
|
||||
static __ri void format_that_ascii_mess( CharBufferType& buffer, uint writepos, const char* fmt, va_list argptr )
|
||||
{
|
||||
va_list args;
|
||||
while( true )
|
||||
{
|
||||
int size = buffer.GetLength();
|
||||
int len = vsnprintf(buffer.GetPtr(writepos), size-writepos, fmt, argptr);
|
||||
|
||||
va_copy(args, argptr);
|
||||
int len = vsnprintf(buffer.GetPtr(writepos), size-writepos, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// some implementations of vsnprintf() don't NUL terminate
|
||||
// the string if there is not enough space for it so
|
||||
|
@ -184,10 +188,14 @@ static __ri void format_that_ascii_mess( CharBufferType& buffer, uint writepos,
|
|||
// returns the length of the formatted string, in characters (wxChars).
|
||||
static __ri uint format_that_unicode_mess( CharBufferType& buffer, uint writepos, const wxChar* fmt, va_list argptr)
|
||||
{
|
||||
va_list args;
|
||||
while( true )
|
||||
{
|
||||
int size = buffer.GetLength() / sizeof(wxChar);
|
||||
int len = wxVsnprintf((wxChar*)buffer.GetPtr(writepos*sizeof(wxChar)), size-writepos, fmt, argptr);
|
||||
|
||||
va_copy(args, argptr);
|
||||
int len = wxVsnprintf((wxChar*)buffer.GetPtr(writepos*sizeof(wxChar)), size-writepos, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// some implementations of vsnprintf() don't NUL terminate
|
||||
// the string if there is not enough space for it so
|
||||
|
|
Loading…
Reference in New Issue