[ASan] Fix use-after-scope in COMMON_INTERCEPTOR_ENTER implementation.
authorAlexey Samsonov <vonosmas@gmail.com>
Tue, 27 Jan 2015 22:50:19 +0000 (22:50 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Tue, 27 Jan 2015 22:50:19 +0000 (22:50 +0000)
Make sure "void *ctx" doesn't point to an object which already went out
of scope. This might also fix -Wuninitialized warnings GCC 4.7 produces
while building ASan runtime.

llvm-svn: 227258

compiler-rt/lib/asan/asan_interceptors.cc

index 2074968..e18790a 100644 (file)
@@ -142,10 +142,10 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
   ASAN_READ_RANGE(ctx, ptr, size)
 #define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)                               \
+  ASAN_INTERCEPTOR_ENTER(ctx, func);                                           \
   do {                                                                         \
     if (asan_init_is_running)                                                  \
       return REAL(func)(__VA_ARGS__);                                          \
-    ASAN_INTERCEPTOR_ENTER(ctx, func);                                         \
     if (SANITIZER_MAC && UNLIKELY(!asan_inited))                               \
       return REAL(func)(__VA_ARGS__);                                          \
     ENSURE_ASAN_INITED();                                                      \