[Mesa-dev] [PATCH] st/mesa: fix segfault in BufferData if size is 0 and buffer is NULL

Jose Fonseca jfonseca at vmware.com
Mon Apr 29 07:26:43 PDT 2013


----- Original Message -----
> I seem to recall adding a bunch of null pointer checks to the
> st_cb_bufferobjects.c code in the past to avoid crashing in some
> out-of-memory situations.  I think we should check for null pointers
> wherever possible.

FWIW, the fix that I suggested privately to Marek did precisely that:

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 1b3991c..be112a6 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -182,7 +182,7 @@ st_bufferobj_data(struct gl_context *ctx,
    struct st_buffer_object *st_obj = st_buffer_object(obj);
    unsigned bind, pipe_usage;
 
-   if (st_obj->Base.Size == size && st_obj->Base.Usage == usage && data) {
+   if (st_obj->Base.Size == size && st_obj->Base.Usage == usage && st_obj->buffer && data) {
       /* Just discard the old contents and write new data.
        * This should be the same as creating a new buffer, but we avoid
        * a lot of validation in Mesa.


But I don't feel strongly either way.  What really matters to me is preventing the segfault, so that the affected tests can complete and we can have the benefit of regression testing.  So in the interim, I reverted the said commit.

Jose


More information about the mesa-dev mailing list