Skip to content

Commit bcbdbd2

Browse files
authored
[llvm][ELF][build attributes] Change StringRef to std::string for BuildAttributeSubSection::Name (#135625)
BuildAttributeSubSection::Name must be a std::string instead of StringRef because it may be assigned from non-persistent memory. StringRef is non-owning and unsafe in this context. This change ensures the subsection name owns its memory, preventing use-after-free or dangling references. Context: Work in progress in PR #131990.
1 parent 74e8f29 commit bcbdbd2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/include/llvm/Support/ELFAttributes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct BuildAttributeItem {
3636
: Type(Ty), Tag(Tg), IntValue(IV), StringValue(std::move(SV)) {}
3737
};
3838
struct BuildAttributeSubSection {
39-
StringRef Name;
39+
std::string Name;
4040
unsigned IsOptional;
4141
unsigned ParameterType;
4242
SmallVector<BuildAttributeItem, 64> Content;

0 commit comments

Comments
 (0)