server: move memset after check
If the malloc fails, memset would touch invalid memory. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
e2c0d47b0c
commit
a92efe9ad6
|
@ -1141,10 +1141,11 @@ wl_display_add_socket_auto(struct wl_display *display)
|
|||
const int MAX_DISPLAYNO = 32;
|
||||
|
||||
s = malloc(sizeof *s);
|
||||
memset(s, 0, sizeof *s);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(s, 0, sizeof *s);
|
||||
|
||||
do {
|
||||
snprintf(display_name, sizeof display_name, "wayland-%d", displayno);
|
||||
if (wl_socket_init_for_display_name(s, display_name) < 0) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user