File tree 1 file changed +6
-12
lines changed
1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -107,23 +107,17 @@ LUA_FUNCTION(LuaThread_SetValue)
107
107
if (type == GarrysMod::Lua::Type::Nil)
108
108
{
109
109
shared_table_mutex.Lock ();
110
- ILuaValue* pKey = nullptr ;
111
- ILuaValue* pVal = nullptr ;
112
- for (auto & [sKey , sVal ] : shared_table)
110
+ for (auto it = shared_table.begin (); it != shared_table.end ();)
113
111
{
114
- if (EqualValue (key, sKey ))
112
+ if (EqualValue (key, it-> first ))
115
113
{
116
- pKey = sKey ;
117
- pVal = sVal ;
114
+ SafeDelete (it->first );
115
+ SafeDelete (it->second );
116
+ it = shared_table.erase (it);
118
117
break ;
119
118
}
120
- }
121
119
122
- if (pKey)
123
- {
124
- shared_table.erase (pKey);
125
- // SafeDelete(pKey); // Potential memory leak? idk but it causes weird behavior.
126
- SafeDelete (pVal);
120
+ ++it;
127
121
}
128
122
shared_table_mutex.Unlock ();
129
123
SafeDelete (key);
You can’t perform that action at this time.
0 commit comments