From 43a619669f51d667fc36b52b1e7984e601307ddf Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 22 Jul 2011 13:15:50 +0100 Subject: [PATCH] Fix memory bug where we were accessing memory that had been freed. (The string for which c_str() was called was just a temporary, so its destructor ran after funcName was initialized, leading funcName to point at freed memory.) --- builtins.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index 8dd13deb..bd6b778f 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -495,10 +495,10 @@ lCheckModuleIntrinsics(llvm::Module *module) { if (!func->isIntrinsic()) continue; - const char *funcName = func->getName().str().c_str(); + const std::string funcName = func->getName().str(); // Work around http://llvm.org/bugs/show_bug.cgi?id=10438; only // check the llvm.x86.* intrinsics for now... - if (!strncmp(funcName, "llvm.x86.", 9)) { + if (!strncmp(funcName.c_str(), "llvm.x86.", 9)) { llvm::Intrinsic::ID id = (llvm::Intrinsic::ID)func->getIntrinsicID(); assert(id != 0); LLVM_TYPE_CONST llvm::Type *intrinsicType =