From f51fcd90b3f08333fc9c2935cfedfc4c8026a7d9 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 17 Jan 2014 18:57:52 +0100 Subject: [PATCH 1/3] - Fixed scanf in IWAD picker without GTK If you try to kill the program with Ctrl-C, it would run the first IWAD available in the list instead of closing it. --- src/sdl/i_system.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index def35606a..b078e6507 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -684,8 +684,7 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad) printf ("%d. %s (%s)\n", i+1, wads[i].Name.GetChars(), filepart); } printf ("Which one? "); - scanf ("%d", &i); - if (i > numwads) + if (scanf ("%d", &i) != 1 || i > numwads) return -1; return i-1; } From aafea851f0fa334efaaafe1271b15dbdb5330854 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 17 Jan 2014 19:11:29 +0100 Subject: [PATCH 2/3] - Remove clang check from GCC-related workaround It caused a clang warning/error regarding the non-existing flags '-fno-tree-dominator-opts' and '-fno-tree-fre'. --- src/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54a72aeae..f43a6a97c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -989,10 +989,11 @@ if( NOT WIN32 ) COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/link-make COMMAND /bin/sh -c ${CMAKE_CURRENT_BINARY_DIR}/link-make ) endif( NOT WIN32 ) -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) # GCC misoptimizes this file set_source_files_properties( oplsynth/fmopl.cpp PROPERTIES COMPILE_FLAGS "-fno-tree-dominator-opts -fno-tree-fre" ) - +endif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) # Need to enable intrinsics for this file. if( SSE_MATTERS ) set_source_files_properties( x86.cpp PROPERTIES COMPILE_FLAGS "-msse2 -mmmx" ) From 884928687dc12967bbb336ee27c09c5396c42896 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Fri, 17 Jan 2014 19:27:12 +0100 Subject: [PATCH 3/3] - Fixed overflow checking in some viewpitch code --- src/g_game.cpp | 4 ++-- src/r_utility.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 081ffdb53..4ba535a00 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -775,7 +775,7 @@ void G_AddViewPitch (int look) else if (look > 0) { // Avoid overflowing - if (LocalViewPitch + look <= LocalViewPitch) + if (LocalViewPitch > INT_MAX - look) { LocalViewPitch = 0x78000000; } @@ -787,7 +787,7 @@ void G_AddViewPitch (int look) else if (look < 0) { // Avoid overflowing - if (LocalViewPitch + look >= LocalViewPitch) + if (LocalViewPitch < INT_MIN - look) { LocalViewPitch = -0x78000000; } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 0b51578ed..19ddaa972 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -602,7 +602,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi if (delta > 0) { // Avoid overflowing viewpitch (can happen when a netgame is stalled) - if (viewpitch + delta <= viewpitch) + if (viewpitch > INT_MAX - delta) { viewpitch = player->MaxPitch; } @@ -614,7 +614,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi else if (delta < 0) { // Avoid overflowing viewpitch (can happen when a netgame is stalled) - if (viewpitch + delta >= viewpitch) + if (viewpitch < INT_MIN - delta) { viewpitch = player->MinPitch; }