Dear Developers,

I would like to propose the patch below to
http://cgit.freedesktop.org/mesa/mesa/plain/src/mesa/main/imports.c

The problem: if posix_memalign returns an error (e.g. ENOMEM), the
function will return an uninitialized value (contents of 'mem'
pointer) as the allocated address, instead of NULL. In my case this
lead to segmentation violations later in the program when calling
other Mesa functions. This happened on linux 2.6.32.

Regards,

Pontus

-- 
Pontus Lidman
Software Manager
27M Technologies
http://www.27m.se


--- imports.c   2010-11-26 11:21:38.528555117 +0100
+++ imports.c.fixed     2010-11-26 11:22:31.870648465 +0100
@@ -88,7 +88,8 @@
 #if defined(HAVE_POSIX_MEMALIGN)
    void *mem;
    int err = posix_memalign(& mem, alignment, bytes);
-   (void) err;
+   if (err)
+       return NULL;
    return mem;
 #elif defined(_WIN32) && defined(_MSC_VER)
    return _aligned_malloc(bytes, alignment);
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to