Skip to content

Commit cc00df0

Browse files
committed
LibELF: Avoid calling strlen() in DynamicObject::hash_section()
The long-term fix here is to make StringView recognize compile-time string literals and do the right thing automatically.
1 parent d6af330 commit cc00df0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Userland/Libraries/LibELF/DynamicObject.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ DynamicObject::Section DynamicObject::fini_array_section() const
235235

236236
DynamicObject::HashSection DynamicObject::hash_section() const
237237
{
238-
const char* section_name = m_hash_type == HashType::SYSV ? "DT_HASH" : "DT_GNU_HASH";
238+
auto section_name = m_hash_type == HashType::SYSV
239+
? StringView { "DT_HASH", 7 }
240+
: StringView { "DT_GNU_HASH", 11 };
239241
return HashSection(Section(*this, m_hash_table_offset, 0, 0, section_name), m_hash_type);
240242
}
241243

0 commit comments

Comments
 (0)