From 92675f6e22a1caa11146c2e9f3b2fb2285fdccea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 14 Aug 2008 10:48:29 +0100 Subject: [PATCH] python: Fix typo in buffer::write. --- src/gallium/state_trackers/python/p_texture.i | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i index fd38e0733fb..06bc1054659 100644 --- a/src/gallium/state_trackers/python/p_texture.i +++ b/src/gallium/state_trackers/python/p_texture.i @@ -183,8 +183,20 @@ struct st_buffer { struct pipe_winsys *winsys = $self->st_dev->screen->winsys; char *map; + assert($self->buffer->refcount); + + if(offset > $self->buffer->size) { + PyErr_SetString(PyExc_ValueError, "offset must be smaller than buffer size"); + return; + } + + if(offset + LENGTH > $self->buffer->size) { + PyErr_SetString(PyExc_ValueError, "data length must fit inside the buffer"); + return; + } + map = winsys->buffer_map(winsys, $self->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); - if(!map) { + if(map) { memcpy(map + offset, STRING, LENGTH); winsys->buffer_unmap(winsys, $self->buffer); } -- 2.30.2