summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/python
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-08-14 10:48:29 +0100
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-08-14 11:01:43 +0100
commit92675f6e22a1caa11146c2e9f3b2fb2285fdccea (patch)
tree4ceec8b127d1bf342e9179cedc668d6ec45f4ed8 /src/gallium/state_trackers/python
parent90ed1742d55a246ffa63e57f291b18a1a43e41ba (diff)
python: Fix typo in buffer::write.
Diffstat (limited to 'src/gallium/state_trackers/python')
-rw-r--r--src/gallium/state_trackers/python/p_texture.i14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i
index fd38e0733f..06bc105465 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);
}