From 5b96d66634d2edf5f8d6d88508156c7544ca5836 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 27 Sep 2010 11:25:20 +0200 Subject: [PATCH] client.content: Use p_new() instead of p_alloca() (FS#824) alloca() allocates stack space. The image that we were producing is possibly huge which means that we were asking for e.g. 9MiB of stack space. This is not really a good idea and caused crashes. Fix this by using heap memory instead. Signed-off-by: Uli Schlachter --- objects/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/objects/client.c b/objects/client.c index 04cac604..ba2fdfb4 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1434,7 +1434,7 @@ luaA_client_get_content(lua_State *L, client_t *c) { if(ximage->bpp >= 24) { - uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height); + uint32_t *data = p_new(uint32_t, ximage->width * ximage->height); for(int y = 0; y < ximage->height; y++) for(int x = 0; x < ximage->width; x++) @@ -1444,6 +1444,7 @@ luaA_client_get_content(lua_State *L, client_t *c) } retval = image_new_from_argb32(L, ximage->width, ximage->height, data); + p_delete(&data); } xcb_image_destroy(ximage); }