From: Torok Edwin Date: Sun, 28 Mar 2010 11:07:36 +0000 (+0000) Subject: Fix use-of-uninitialized value when RWX memory can't be allocated (PR6701). X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=b4bc96317a64b5f824ebef4b0c1c7024017f52c6 Fix use-of-uninitialized value when RWX memory can't be allocated (PR6701). SELinux doesn't allow 'execmem', returning MAP_FAILED and 'Permission denied' for mmap or RWX memory. In this case AllocateRWX was returning a MemoryBlock with uninitialized fields, which sometimes caused crashes. This patch initializes MemoryBlock fields to 0, so that the RWX-failure check works. It doesn't fix the SELinux 'execmem' issues though (the JIT will not work when SELinux is in enforcing mode). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99762 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/System/Memory.h b/include/llvm/System/Memory.h index 69251dd2bfb..01bcab1f007 100644 --- a/include/llvm/System/Memory.h +++ b/include/llvm/System/Memory.h @@ -27,7 +27,7 @@ namespace sys { /// @brief Memory block abstraction. class MemoryBlock { public: - MemoryBlock() { } + MemoryBlock() : Address(0), Size(0) { } MemoryBlock(void *addr, size_t size) : Address(addr), Size(size) { } void *base() const { return Address; } size_t size() const { return Size; }