From fa89775626d491e701cc1b70509d829cbbcf8eb9 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 4 Sep 2009 12:38:06 +0200 Subject: [PATCH] Add some missing luaA_checkudata() calls luaA_object_ref_item doesn't check the type of object it returns which resulted in stuff like this: wibox.shape_clip = wibox wibox.shape_bounding = wibox imagebox.image = imagebox textbox.bg_image = textbox All of the above calls would result in a crash (unverified) and all of them where fixed. This should fix all places which use luaA_object_ref_item(). The others already did a proper type check. Signed-off-by: Uli Schlachter Signed-off-by: Julien Danjou --- wibox.c | 2 ++ widgets/imagebox.c | 1 + widgets/textbox.c | 1 + 3 files changed, 4 insertions(+) diff --git a/wibox.c b/wibox.c index a6e96100..3c51f664 100644 --- a/wibox.c +++ b/wibox.c @@ -1463,6 +1463,7 @@ luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox) static int luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox) { + luaA_checkudata(L, -1, &image_class); luaA_object_unref_item(L, -3, wibox->shape.bounding); wibox->shape.bounding = luaA_object_ref_item(L, -3, -1); wibox->need_shape_update = true; @@ -1479,6 +1480,7 @@ luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox) static int luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox) { + luaA_checkudata(L, -1, &image_class); luaA_object_unref_item(L, -3, wibox->shape.clip); wibox->shape.clip = luaA_object_ref_item(L, -3, -1); wibox->need_shape_update = true; diff --git a/widgets/imagebox.c b/widgets/imagebox.c index b9132823..45a5dadf 100644 --- a/widgets/imagebox.c +++ b/widgets/imagebox.c @@ -133,6 +133,7 @@ luaA_imagebox_newindex(lua_State *L, awesome_token_t token) size_t len; case A_TK_IMAGE: + luaA_checkudata(L, 1, &image_class); luaA_object_unref_item(L, 1, d->image); d->image = luaA_object_ref_item(L, 1, 3); break; diff --git a/widgets/textbox.c b/widgets/textbox.c index 42a04540..598572ca 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -346,6 +346,7 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token) d->bg_resize = luaA_checkboolean(L, 3); break; case A_TK_BG_IMAGE: + luaA_checkudata(L, 1, &image_class); luaA_object_unref_item(L, 1, d->bg_image); d->bg_image = luaA_object_ref_item(L, 1, 3); break;