From d8f537cd1bd2a4fff8edfa704038bf9ada54e287 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Mon, 1 Sep 2003 01:21:45 +0000 Subject: [PATCH] Fixed a problem where bad actions (MenuUp instead of Menu-Up) crashed during initKeyConfig. The action-listener table needs to be null-terminated. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1166 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/sc2code/libs/input/sdl/input.c | 3 ++- sc2/src/sc2code/libs/input/sdl/vcontrol.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index c619c182a..ce95d9724 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.3: +- Action names are properly null-terminated, stops a crash for some + bad keys.cfg types -Michael - added '--addon ' - SvdB - keys.cfg from incompatible control scheme version is now renamed automatically to keys.old -Mika diff --git a/sc2/src/sc2code/libs/input/sdl/input.c b/sc2/src/sc2code/libs/input/sdl/input.c index c35507053..786608165 100644 --- a/sc2/src/sc2code/libs/input/sdl/input.c +++ b/sc2/src/sc2code/libs/input/sdl/input.c @@ -73,7 +73,8 @@ static VControl_NameBinding control_names[] = { { "Pause", (int *)&ImmediateInputState.pause }, { "Exit", (int *)&ImmediateInputState.exit }, { "Abort", (int *)&ImmediateInputState.abort }, - { "Debug", (int *)&ImmediateInputState.debug }}; + { "Debug", (int *)&ImmediateInputState.debug }, + { "Illegal", NULL}}; static void diff --git a/sc2/src/sc2code/libs/input/sdl/vcontrol.c b/sc2/src/sc2code/libs/input/sdl/vcontrol.c index 828979842..690a056e4 100644 --- a/sc2/src/sc2code/libs/input/sdl/vcontrol.c +++ b/sc2/src/sc2code/libs/input/sdl/vcontrol.c @@ -1075,13 +1075,13 @@ _consume_idname (parse_state *state) state->token[index] = 0; /* remove trailing colon */ result = _name2target (state->token); - _next_token (state); if (!result) { fprintf (stderr, "VControl: Illegal command type '%s' on config file line %d\n", state->token, state->linenum); state->error = 1; } + _next_token (state); return result; }