diff options
author | Robert Bragg <robert@linux.intel.com> | 2013-02-28 17:48:34 +0000 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2013-03-06 16:44:52 +0000 |
commit | b62b9a68bbc3303810576480b39cd2ec20a2ceae (patch) | |
tree | 00e4df5e5de3086bbb6bd807e49572a6091899f8 /cogl/cogl-bitmap.c | |
parent | bfea34b897ec7ff4a15d1791c2f0c430fa20053f (diff) | |
download | cogl-b62b9a68bbc3303810576480b39cd2ec20a2ceae.tar.gz |
bitmap: don't mark bitmap bound on _gl_bind error
This makes some changes to _cogl_bitmap_gl_bind to be more paranoid
about bad access arguments and make sure we don't mark a bitmap as bound
if there was an error in _cogl_buffer_gl_bind.
We now validate the access argument upfront to check that one of _READ
or _WRITE access has been requested. In the case that cogl is built
without debug support then we will still detect a bad access argument
later and now explicitly return before marking the bitmap as bound, just
in case the g_assert_not_reach has been somehow disabled. Finally we
defer setting bitmap->bound = TRUE until after we have check for any
error with _cogl_bitmap_gl_bind.
https://bugzilla.gnome.org/show_bug.cgi?id=686770
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 1720d5cf32449a189fd9d400cf5e6696cd50a9fa)
Diffstat (limited to 'cogl/cogl-bitmap.c')
-rw-r--r-- | cogl/cogl-bitmap.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index 269b5ede..58890fcf 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -447,6 +447,10 @@ _cogl_bitmap_gl_bind (CoglBitmap *bitmap, uint8_t *ptr; CoglError *internal_error = NULL; + g_return_val_if_fail (access & (COGL_BUFFER_ACCESS_READ | + COGL_BUFFER_ACCESS_WRITE), + NULL); + /* Divert to another bitmap if this data is shared */ if (bitmap->shared_bmp) return _cogl_bitmap_gl_bind (bitmap->shared_bmp, access, hints, error); @@ -463,8 +467,6 @@ _cogl_bitmap_gl_bind (CoglBitmap *bitmap, return data; } - bitmap->bound = TRUE; - if (access == COGL_BUFFER_ACCESS_READ) ptr = _cogl_buffer_gl_bind (bitmap->buffer, COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK, @@ -477,6 +479,7 @@ _cogl_bitmap_gl_bind (CoglBitmap *bitmap, { ptr = NULL; g_assert_not_reached (); + return NULL; } /* NB: _cogl_buffer_gl_bind() may return NULL in non-error @@ -488,6 +491,8 @@ _cogl_bitmap_gl_bind (CoglBitmap *bitmap, return NULL; } + bitmap->bound = TRUE; + /* The data pointer actually stores the offset */ return ptr + GPOINTER_TO_INT (bitmap->data); } |