From 375fa0c94f053ef97690272c4469e79eb9200605 Mon Sep 17 00:00:00 2001 From: riccardom Date: Mon, 12 Sep 2011 17:37:28 +0000 Subject: [PATCH] Fix libagg crashes on 64bit Putting a "\n" in OSDCLASS->addLine SIGSEGVs. A newline is 10 in ASCII while the libagg's font starts from a 32 (a space), so it nicely underflows and accesses out-of-bounds memory in agg_glyph_raster_bin.h:90: m_font + 4 + (glyph - start_char) * 2 m_font + 4 + (16 - 32) * 2 Should fix #2829308 Patch from kouteiheika, #3407304 --- desmume/src/ctrlssdl.cpp | 10 +++++----- desmume/src/gtk/main.cpp | 8 ++++---- desmume/src/wx/wxMain.cpp | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/desmume/src/ctrlssdl.cpp b/desmume/src/ctrlssdl.cpp index 8e3ba39e5..700f7edb1 100644 --- a/desmume/src/ctrlssdl.cpp +++ b/desmume/src/ctrlssdl.cpp @@ -436,7 +436,7 @@ process_ctrls_event( SDL_Event& event, if (event.active.gain) { cfg->focused = 1; SPU_Pause(0); - osd->addLine("Auto pause disabled\n"); + osd->addLine("Auto pause disabled"); } else { cfg->focused = 0; SPU_Pause(1); @@ -470,18 +470,18 @@ process_ctrls_event( SDL_Event& event, cfg->fake_mic = !cfg->fake_mic; Mic_DoNoise(cfg->fake_mic); if (cfg->fake_mic) - osd->addLine("Fake mic enabled\n"); + osd->addLine("Fake mic enabled"); else - osd->addLine("Fake mic disabled\n"); + osd->addLine("Fake mic disabled"); break; #endif case SDLK_o: cfg->boost = !cfg->boost; if (cfg->boost) - osd->addLine("Boost mode enabled\n"); + osd->addLine("Boost mode enabled"); else - osd->addLine("Boost mode disabled\n"); + osd->addLine("Boost mode disabled"); break; case SDLK_LSHIFT: diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index a2f3a45df..a958e0c5e 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -2004,10 +2004,10 @@ static void ToggleAudio (GtkToggleAction *action) { if (gtk_toggle_action_get_active(action) == TRUE) { SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - osd->addLine("Audio enabled\n"); + osd->addLine("Audio enabled"); } else { SPU_ChangeSoundCore(0, 0); - osd->addLine("Audio disabled\n"); + osd->addLine("Audio disabled"); } } @@ -2018,9 +2018,9 @@ static void ToggleMicNoise (GtkToggleAction *action) Mic_DoNoise(doNoise); if (doNoise) - osd->addLine("Fake mic enabled\n"); + osd->addLine("Fake mic enabled"); else - osd->addLine("Fake mic disabled\n"); + osd->addLine("Fake mic disabled"); } #endif diff --git a/desmume/src/wx/wxMain.cpp b/desmume/src/wx/wxMain.cpp index 9ac845551..63e2504d5 100644 --- a/desmume/src/wx/wxMain.cpp +++ b/desmume/src/wx/wxMain.cpp @@ -680,12 +680,12 @@ void DesmumeFrame::Modify_AudioDriver(wxCommandEvent &event) switch (selection) { case AUDIODRIVER_DISABLE: SPU_ChangeSoundCore(0, 0); - osd->addLine("Audio disabled\n"); + osd->addLine("Audio disabled"); break; default: case AUDIODRIVER_SDL: SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - osd->addLine("Audio enabled (SDL driver)\n"); + osd->addLine("Audio enabled (SDL driver)"); break; } }