Skip to content

Commit 9ab4104

Browse files
committed
Correct std::string_view::empty usage
1 parent 23b7f16 commit 9ab4104

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/linux/module.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ bool CModule::LoadFromPath(const std::string_view svModelePath, int flags)
158158
//-----------------------------------------------------------------------------
159159
CMemory CModule::GetVirtualTableByName(const std::string_view svTableName, bool bDecorated) const
160160
{
161-
assert(!svTableName.empty());
161+
if (svTableName.empty())
162+
return DYNLIB_INVALID_MEMORY;
162163

163164
const Section_t *pReadOnlyData = GetSectionByName(".rodata"), *pReadOnlyRelocations = GetSectionByName(".data.rel.ro");
164165

src/windows/module.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool CModule::InitFromName(const std::string_view svModuleName, bool bExtension)
5555
if (IsValid())
5656
return false;
5757

58-
if (!svModuleName.empty())
58+
if (svModuleName.empty())
5959
return false;
6060

6161
std::string sModuleName(svModuleName);
@@ -143,8 +143,9 @@ bool CModule::LoadFromPath(const std::string_view svModelePath, int flags)
143143
//-----------------------------------------------------------------------------
144144
CMemory CModule::GetVirtualTableByName(const std::string_view svTableName, bool bDecorated) const
145145
{
146-
assert(!svTableName.empty());
147-
146+
if (svTableName.empty())
147+
return DYNLIB_INVALID_MEMORY;
148+
148149
const Section_t *pRunTimeData = GetSectionByName(".data"), *pReadOnlyData = GetSectionByName(".rdata");
149150

150151
assert(pRunTimeData != nullptr);

0 commit comments

Comments
 (0)