Jakub Jelinek 6e8885
--- valgrind-3.2.3/coregrind/m_syswrap/syswrap-linux.c.jj	2007-06-27 12:22:59.000000000 +0200
Jakub Jelinek 6e8885
+++ valgrind-3.2.3/coregrind/m_syswrap/syswrap-linux.c	2007-06-27 12:37:18.000000000 +0200
Jakub Jelinek 6e8885
@@ -1213,16 +1213,18 @@ POST(sys_io_setup)
Jakub Jelinek 6e8885
 PRE(sys_io_destroy)
Jakub Jelinek 6e8885
 {
Jakub Jelinek 6e8885
    struct vki_aio_ring *r;
Jakub Jelinek 6e8885
-   SizeT size;
Jakub Jelinek 6e8885
-      
Jakub Jelinek 6e8885
+   SizeT size = 0;
Jakub Jelinek 6e8885
+
Jakub Jelinek 6e8885
    PRINT("sys_io_destroy ( %llu )", (ULong)ARG1);
Jakub Jelinek 6e8885
    PRE_REG_READ1(long, "io_destroy", vki_aio_context_t, ctx);
Jakub Jelinek 6e8885
 
Jakub Jelinek 6e8885
    // If we are going to seg fault (due to a bogus ARG1) do it as late as
Jakub Jelinek 6e8885
    // possible...
Jakub Jelinek 6e8885
-   r = (struct vki_aio_ring *)ARG1;
Jakub Jelinek 6e8885
-   size = VG_PGROUNDUP(sizeof(struct vki_aio_ring) + 
Jakub Jelinek 6e8885
-                       r->nr*sizeof(struct vki_io_event));
Jakub Jelinek 6e8885
+   if (ML_(safe_to_deref)( (void*)ARG1, sizeof(struct vki_aio_ring))) {
Jakub Jelinek 6e8885
+      r = (struct vki_aio_ring *)ARG1;
Jakub Jelinek 6e8885
+      size = VG_PGROUNDUP(sizeof(struct vki_aio_ring) + 
Jakub Jelinek 6e8885
+                          r->nr*sizeof(struct vki_io_event));
Jakub Jelinek 6e8885
+   }
Jakub Jelinek 6e8885
 
Jakub Jelinek 6e8885
    SET_STATUS_from_SysRes( VG_(do_syscall1)(SYSNO, ARG1) );
Jakub Jelinek 6e8885