File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -737,14 +737,16 @@ bool SampleProfileMatcher::functionMatchesProfileHelper(
737737 auto FunctionName = FName.str ();
738738 if (Demangler.partialDemangle (FunctionName.c_str ()))
739739 return std::string ();
740- constexpr size_t MaxBaseNameSize = 65536 ;
741- std::vector<char > BaseNameBuf (MaxBaseNameSize, 0 );
742- size_t BaseNameSize = MaxBaseNameSize;
743- char *BaseNamePtr =
744- Demangler.getFunctionBaseName (BaseNameBuf.data (), &BaseNameSize);
745- return (BaseNamePtr && BaseNameSize)
746- ? std::string (BaseNamePtr, BaseNameSize)
747- : std::string ();
740+ size_t BaseNameSize = 0 ;
741+ // The demangler API follows the __cxa_demangle one, and thus needs a
742+ // pointer that originates from malloc (or nullptr) and the caller is
743+ // responsible for free()-ing the buffer.
744+ char *BaseNamePtr = Demangler.getFunctionBaseName (nullptr , &BaseNameSize);
745+ std::string Result = (BaseNamePtr && BaseNameSize)
746+ ? std::string (BaseNamePtr, BaseNameSize)
747+ : std::string ();
748+ free (BaseNamePtr);
749+ return Result;
748750 };
749751 auto IRBaseName = GetBaseName (IRFunc.getName ());
750752 auto ProfBaseName = GetBaseName (ProfFunc.stringRef ());
You can’t perform that action at this time.
0 commit comments