GUACAMOLE-424: Return NULL if guac_common_display allocation fails
This commit is contained in:
parent
da0fc1a6d8
commit
f7990af6d0
@ -99,6 +99,19 @@ static void guac_common_display_free_layers(guac_common_display_layer* layers,
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a display and a cursor which are used to represent the remote
|
||||
* display and cursor. If the allocation fails then the function returns NULL.
|
||||
*
|
||||
* @param client
|
||||
* The client owning the cursor.
|
||||
*
|
||||
* @param width
|
||||
* The desired width of the display.
|
||||
*
|
||||
* @param height
|
||||
* The desired height of the display.
|
||||
*/
|
||||
guac_common_display* guac_common_display_alloc(guac_client* client,
|
||||
int width, int height) {
|
||||
|
||||
@ -107,14 +120,18 @@ guac_common_display* guac_common_display_alloc(guac_client* client,
|
||||
if (display == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Allocate shared cursor */
|
||||
display->cursor = guac_common_cursor_alloc(client);
|
||||
if (display->cursor == NULL) {
|
||||
free(display);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&display->_lock, NULL);
|
||||
|
||||
/* Associate display with given client */
|
||||
display->client = client;
|
||||
|
||||
/* Allocate shared cursor */
|
||||
display->cursor = guac_common_cursor_alloc(client);
|
||||
|
||||
display->default_surface = guac_common_surface_alloc(client,
|
||||
client->socket, GUAC_DEFAULT_LAYER, width, height);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user