From 1ef5ad9b32674372bc89c79a0d6b046b1cc7bfad Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Mon, 25 May 2015 11:54:50 +0200 Subject: [PATCH] Fix use-after-free bug in typeCode `edm::TypeWithDict::name()` returns a `std::string`. The code was taking a pointer to temporary string. Thus causing CutParser to fail depending on random values in memory. Signed-off-by: David Abdurachmanov --- CommonTools/Utils/src/returnType.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CommonTools/Utils/src/returnType.cc b/CommonTools/Utils/src/returnType.cc index 39015cada23e8..b3b7d410ffd46 100755 --- a/CommonTools/Utils/src/returnType.cc +++ b/CommonTools/Utils/src/returnType.cc @@ -43,9 +43,9 @@ namespace reco { TypeCode typeCode(const edm::TypeWithDict& t) { typedef std::pair Values; - const char* name = t.name().c_str(); + std::string name = t.name(); auto f = std::equal_range(retTypeVec.begin(), retTypeVec.end(), - Values{name, enumType}, + Values{name.c_str(), enumType}, [](const Values& iLHS, const Values& iRHS) -> bool { return std::strcmp(iLHS.first, iRHS.first) < 0; });