server: fail on global name overflow

display->id is initialized to 1, making 0 a convenient value to
indicate an invalid global name. Make sure to not return a zero
global name on overflow. Moreover, if we wrap around, we might
cycle back to a global name which is already in-use.

Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
Simon Ser 2023-01-24 23:51:57 +01:00
parent 9700155eda
commit be31c5a8c8

View file

@ -1285,6 +1285,11 @@ wl_global_create(struct wl_display *display,
return NULL;
}
if (display->id >= UINT32_MAX) {
wl_log("wl_global_create: ran out of global names\n");
return NULL;
}
global = zalloc(sizeof *global);
if (global == NULL)
return NULL;