diff options
| author | Matthias Clasen <mclasen@redhat.com> | 2023-05-05 09:42:34 -0400 |
|---|---|---|
| committer | Matthias Clasen <mclasen@redhat.com> | 2023-05-05 12:05:10 -0400 |
| commit | 2b85c49fb15040ce38db4385f2d046a5f6beeba4 (patch) | |
| tree | 4dfd9663e5a6d421f2e07e5f7addda3adc3a9c20 | |
| parent | d7c3235cd06ce561ec7a023afbb8c994bf90df74 (diff) | |
| download | gtk+-2b85c49fb15040ce38db4385f2d046a5f6beeba4.tar.gz | |
gsk: Add a few assertions
Make sure we don't overflow our fixed-size arrays.
| -rw-r--r-- | gsk/gl/gskglattachmentstate.c | 1 | ||||
| -rw-r--r-- | gsk/gl/gskglcommandqueue.c | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/gsk/gl/gskglattachmentstate.c b/gsk/gl/gskglattachmentstate.c index f3f62cb210..92fe871a3a 100644 --- a/gsk/gl/gskglattachmentstate.c +++ b/gsk/gl/gskglattachmentstate.c @@ -78,6 +78,7 @@ gsk_gl_attachment_state_bind_texture (GskGLAttachmentState *self, target == GL_TEXTURE_2D || target == GL_TEXTURE_3D); g_assert (texture >= GL_TEXTURE0 && texture <= GL_TEXTURE16); + g_assert (texture - GL_TEXTURE0 < G_N_ELEMENTS (self->textures)); attach = &self->textures[texture - GL_TEXTURE0]; diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c index 774b957785..50c9c3908c 100644 --- a/gsk/gl/gskglcommandqueue.c +++ b/gsk/gl/gskglcommandqueue.c @@ -1161,6 +1161,8 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self, if G_UNLIKELY (batch->draw.bind_count > 0) { const GskGLCommandBind *bind = &self->batch_binds.items[batch->draw.bind_offset]; + + g_assert (bind->texture < G_N_ELEMENTS (textures)); for (guint i = 0; i < batch->draw.bind_count; i++) { if (textures[bind->texture] != bind->id) |
