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 <psychon@znc.in>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Uli Schlachter 2009-09-04 12:38:06 +02:00 committed by Julien Danjou
parent 769d2899ac
commit fa89775626
3 changed files with 4 additions and 0 deletions

View File

@ -1463,6 +1463,7 @@ luaA_wibox_set_border_width(lua_State *L, wibox_t *wibox)
static int static int
luaA_wibox_set_shape_bounding(lua_State *L, wibox_t *wibox) 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); luaA_object_unref_item(L, -3, wibox->shape.bounding);
wibox->shape.bounding = luaA_object_ref_item(L, -3, -1); wibox->shape.bounding = luaA_object_ref_item(L, -3, -1);
wibox->need_shape_update = true; wibox->need_shape_update = true;
@ -1479,6 +1480,7 @@ luaA_wibox_get_shape_bounding(lua_State *L, wibox_t *wibox)
static int static int
luaA_wibox_set_shape_clip(lua_State *L, wibox_t *wibox) 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); luaA_object_unref_item(L, -3, wibox->shape.clip);
wibox->shape.clip = luaA_object_ref_item(L, -3, -1); wibox->shape.clip = luaA_object_ref_item(L, -3, -1);
wibox->need_shape_update = true; wibox->need_shape_update = true;

View File

@ -133,6 +133,7 @@ luaA_imagebox_newindex(lua_State *L, awesome_token_t token)
size_t len; size_t len;
case A_TK_IMAGE: case A_TK_IMAGE:
luaA_checkudata(L, 1, &image_class);
luaA_object_unref_item(L, 1, d->image); luaA_object_unref_item(L, 1, d->image);
d->image = luaA_object_ref_item(L, 1, 3); d->image = luaA_object_ref_item(L, 1, 3);
break; break;

View File

@ -346,6 +346,7 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
d->bg_resize = luaA_checkboolean(L, 3); d->bg_resize = luaA_checkboolean(L, 3);
break; break;
case A_TK_BG_IMAGE: case A_TK_BG_IMAGE:
luaA_checkudata(L, 1, &image_class);
luaA_object_unref_item(L, 1, d->bg_image); luaA_object_unref_item(L, 1, d->bg_image);
d->bg_image = luaA_object_ref_item(L, 1, 3); d->bg_image = luaA_object_ref_item(L, 1, 3);
break; break;