From: José Fonseca Date: Thu, 14 Aug 2008 09:48:29 +0000 (+0100) Subject: python: Fix typo in buffer::write. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=92675f6e22a1caa11146c2e9f3b2fb2285fdccea;p=mesa.git python: Fix typo in buffer::write. --- 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); }