From 71f4ce95d24de080cfca2215eba3b262ada137b0 Mon Sep 17 00:00:00 2001 From: Allanis Date: Wed, 28 May 2014 21:32:48 +0100 Subject: [PATCH] [Fix] Another possible segfault with isspace(). --- src/intro.c | 6 ++++-- src/lstd.h | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intro.c b/src/intro.c index b2f3c8f..510ce8a 100644 --- a/src/intro.c +++ b/src/intro.c @@ -13,6 +13,7 @@ #include "ldata.h" #include "font.h" #include "music.h" +#include "lstd.h" #include "intro.h" #define INTRO_FONT_SIZE 18. /**< Intro text font size. */ @@ -129,9 +130,10 @@ int intro_display(void) { /* Skip the boring intro we saw a million times already! */ if(event.key.keysym.sym == SDLK_ESCAPE) offset = max * (intro_font.h + 5.); - else if(!isspace(event.key.keysym.sym)) + /* Only handle space from here down. */ + else if(!lstd_isspace(event.key.keysym.sym)) break; - /* Purpose fallthrough. */ + /* Purpose fallthrough. */ case SDL_JOYBUTTONDOWN: offset += 250.; default: diff --git a/src/lstd.h b/src/lstd.h index f4b512c..035cc58 100644 --- a/src/lstd.h +++ b/src/lstd.h @@ -21,3 +21,8 @@ */ #define lstd_iscntrl(k) (lstd_checkascii(k) ? iscntrl(k) : 0) +/** + * @brief Check to see if a key is a space character. + */ +#define lstd_isspace(k) (lstd_checkascii(k) ? isspace(k) : 0) +