summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2014-01-14 17:18:03 (GMT)
committerKristian Høgsberg <krh@bitplanet.net>2014-01-15 18:46:09 (GMT)
commit32b2baaf511b982b5af1555b511a2b2abaf7ae7d (patch)
tree3cea378638990c9dca74c52f7cb8196f38586645
parent02952d040cce73c167eaaafe94748a253cd74f02 (diff)
downloadwayland-32b2baaf511b982b5af1555b511a2b2abaf7ae7d.tar.gz
wayland-32b2baaf511b982b5af1555b511a2b2abaf7ae7d.tar.xz
add_shm_format: check wl_array_add return value before deref
In wl_display_add_shm_format(), check the return value from wl_array_add() before dereferencing it and assigning it a value. Return the resulting pointer back to the caller. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
-rw-r--r--src/wayland-server.c14
-rw-r--r--src/wayland-server.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 1459e09..489b99d 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1317,25 +1317,31 @@ wl_display_remove_global(struct wl_display *display, struct wl_global *global)
*
* \param display The display object
* \param format The wl_shm pixel format to advertise
+ * \return A pointer to the wl_shm format that was added to the list
+ * or NULL if adding it to the list failed.
*
* Add the specified wl_shm format to the list of formats the wl_shm
* object advertises when a client binds to it. Adding a format to
* the list means that clients will know that the compositor supports
* this format and may use it for creating wl_shm buffers. The
- * compositor must be able to handle the pixel format when a client
+ * compositor must be able to handle the pixel format when a client
+ * requests it.
*
* The compositor by default supports WL_SHM_FORMAT_ARGB8888 and
* WL_SHM_FORMAT_XRGB8888.
*
* \memberof wl_display
*/
-WL_EXPORT void
+WL_EXPORT uint32_t *
wl_display_add_shm_format(struct wl_display *display, uint32_t format)
{
- uint32_t *p;
+ uint32_t *p = NULL;
p = wl_array_add(&display->additional_shm_formats, sizeof *p);
- *p = format;
+
+ if (p != NULL)
+ *p = format;
+ return p;
}
/**
diff --git a/src/wayland-server.h b/src/wayland-server.h
index f5427fd..3fcaaf6 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -439,7 +439,7 @@ wl_shm_buffer_get_height(struct wl_shm_buffer *buffer);
int
wl_display_init_shm(struct wl_display *display);
-void
+uint32_t *
wl_display_add_shm_format(struct wl_display *display, uint32_t format);
struct wl_shm_buffer *