From 89a05b6b885e4137f3d77dd006a31df81182587c Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Mon, 17 Mar 2008 23:58:36 -0500 Subject: add error checking for character modes --- src/curses.c | 3 +++ src/strings.c | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/curses.c b/src/curses.c index 9fcfa09..34809f9 100644 --- a/src/curses.c +++ b/src/curses.c @@ -125,6 +125,9 @@ static int get_char_attr(lua_State* L, int stack_pos) int cur_mode; cur_mode = get_mode_enum(str); + if (cur_mode == -1) { + return luaL_error(L, "Unknown attribute %s", str); + } lua_toboolean(L, -1) ? (mode |= cur_mode) : (mode &= ~cur_mode); } diff --git a/src/strings.c b/src/strings.c index 0eca298..1a211a2 100644 --- a/src/strings.c +++ b/src/strings.c @@ -142,11 +142,7 @@ int get_color_enum(const char* str) int get_mode_enum(const char* str) { - int ret; - - ret = str2enum(modes, lengthof(modes), str); - - return ret == -1 ? A_NORMAL : ret; + return str2enum(modes, lengthof(modes), str); } int get_key_enum(const char* str) -- cgit v1.2.3