diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h index 777bf74825..c5497d1b5d 100644 --- a/common/include/PS2Edefs.h +++ b/common/include/PS2Edefs.h @@ -278,7 +278,7 @@ void CALLBACK GSsetFrameSkip(int frameskip); int CALLBACK GSsetupRecording(int start, void* pData); void CALLBACK GSreset(); -void CALLBACK GSgetTitleInfo( char dest[128] ); +void CALLBACK GSgetTitleInfo( char* dest, size_t length ); void CALLBACK GSwriteCSR(u32 value); s32 CALLBACK GSfreeze(int mode, freezeData *data); void CALLBACK GSconfigure(); @@ -575,7 +575,7 @@ typedef void (CALLBACK* _GSreadFIFO)(u64 *pMem); typedef void (CALLBACK* _GSreadFIFO2)(u64 *pMem, int qwc); typedef void (CALLBACK* _GSchangeSaveState)(int, const char* filename); -typedef void (CALLBACK* _GSgetTitleInfo)(char dest[128]); +typedef void (CALLBACK* _GSgetTitleInfo)(char* dest, size_t length); typedef void (CALLBACK* _GSirqCallback)(void (*callback)()); typedef void (CALLBACK* _GSprintf)(int timeout, char *fmt, ...); typedef void (CALLBACK* _GSsetBaseMem)(void*); diff --git a/pcsx2/PluginManager.cpp b/pcsx2/PluginManager.cpp index 4a82c31b4b..ee37878c40 100644 --- a/pcsx2/PluginManager.cpp +++ b/pcsx2/PluginManager.cpp @@ -185,7 +185,7 @@ static void CALLBACK GS_printf(int timeout, char *fmt, ...) Console.WriteLn(msg); } -void CALLBACK GS_getTitleInfo( char dest[128] ) +void CALLBACK GS_getTitleInfo( char* dest, size_t length ) { // Just return a generic "GS" title -- a plugin actually implementing this feature // should return a title such as "GSdx" or "ZZogl" instead. --air diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index 63333c8450..964660591e 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -386,7 +386,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt ) double fps = wxGetApp().FpsManager.GetFramerate(); char gsDest[128]; - GSgetTitleInfo( gsDest ); + GSgetTitleInfo( gsDest, sizeof(gsDest) ); const wxChar* limiterStr = L"None"; diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index d561641424..9ada2ebaa9 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -478,18 +478,15 @@ EXPORT_C GSgetLastTag(uint32* tag) #define snprintf _snprintf #endif -EXPORT_C GSgetTitleInfo(char dest[128]) +EXPORT_C GSgetTitleInfo(char* dest, size_t length) { - // NOTE: MSVC appears to generate an incorrect sizeof for dest, returning 4 (size of a pointer) - // instead of 128. So let's hardcode it. (sigh). --air - if (!s_gs->m_GStitleInfoBuffer[0]) strcpy(dest, "GSdx"); else { EnterCriticalSection(&s_gs->m_pGSsetTitle_Crit); - snprintf(dest, 127, "GSdx | %s", s_gs->m_GStitleInfoBuffer); - dest[127] = 0; // just in case! + snprintf(dest, length-1, "GSdx | %s", s_gs->m_GStitleInfoBuffer); + dest[length-1] = 0; // just in case! LeaveCriticalSection(&s_gs->m_pGSsetTitle_Crit); } }