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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-09-27 11:25:20 +02:00
parent dd656f514a
commit 5b96d66634
1 changed files with 2 additions and 1 deletions

View File

@ -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);
}