vl: Fix off-by-one error in device_name_length allocation.

Fixes out-of-bounds write reported by Coverity.

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel@daenzer.net>
This commit is contained in:
Vinson Lee 2013-02-22 20:33:54 -08:00
parent 65aa1a194d
commit f6487e8911

View file

@ -338,9 +338,8 @@ vl_screen_create(Display *display, int screen)
goto free_screen;
device_name_length = xcb_dri2_connect_device_name_length(connect);
device_name = CALLOC(1, device_name_length);
device_name = CALLOC(1, device_name_length + 1);
memcpy(device_name, xcb_dri2_connect_device_name(connect), device_name_length);
device_name[device_name_length] = 0;
fd = open(device_name, O_RDWR);
free(device_name);