]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix the mmap2 pre-handler to avoid corrupting the arguments when
authorTom Hughes <tom@compton.nu>
Tue, 19 Jul 2005 13:04:04 +0000 (13:04 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 19 Jul 2005 13:04:04 +0000 (13:04 +0000)
it fails with ENOMEM due to a lack of memory.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4184

coregrind/m_syswrap/syswrap-generic.c

index 8d72deb32fb50dbdfe717b580092ea04c2881694..64344a4597762e6b169d00ce63259e3cdcfadec3 100644 (file)
@@ -4487,13 +4487,13 @@ PRE(sys_mmap2)
    } else {
       Addr a = VG_(find_map_space)(ARG1, ARG2, True);
       if (a == 0 && ARG1 != 0)
-         ARG1 = VG_(find_map_space)(0, ARG2, True);
-      else
-         ARG1 = a;
-      if (ARG1 == 0)
+         a = VG_(find_map_space)(0, ARG2, True);
+      if (a == 0) {
         SET_STATUS_Failure( VKI_ENOMEM );
-      else 
+      } else {
+         ARG1 = a;
          ARG4 |= VKI_MAP_FIXED;
+      }
    }
 }