@@ -230,18 +230,22 @@ int CLuaCryptDefs::PasswordHash(lua_State* luaVM)
230
230
// Execute time-consuming task
231
231
return SharedUtil::BcryptHash (password, salt, cost);
232
232
233
- }, [luaFunctionRef, pLuaMain](const SString& hash) {
234
- CLuaArguments arguments;
235
-
236
- if (hash.empty ())
233
+ }, [luaFunctionRef](const SString& hash) {
234
+ CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine (luaFunctionRef.GetLuaVM ());
235
+ if (pLuaMain)
237
236
{
238
- m_pScriptDebugging->LogCustom (pLuaMain->GetVM (), " Invalid value for field 'salt'" );
239
- arguments.PushBoolean (false );
240
- }
241
- else
242
- arguments.PushString (hash);
237
+ CLuaArguments arguments;
243
238
244
- arguments.Call (pLuaMain, luaFunctionRef);
239
+ if (hash.empty ())
240
+ {
241
+ m_pScriptDebugging->LogCustom (pLuaMain->GetVM (), " Invalid value for field 'salt'" );
242
+ arguments.PushBoolean (false );
243
+ }
244
+ else
245
+ arguments.PushString (hash);
246
+
247
+ arguments.Call (pLuaMain, luaFunctionRef);
248
+ }
245
249
});
246
250
247
251
lua_pushboolean (luaVM, true );
@@ -295,11 +299,14 @@ int CLuaCryptDefs::PasswordVerify(lua_State* luaVM)
295
299
// Execute time-consuming task
296
300
return SharedUtil::BcryptVerify (password, hash);
297
301
298
- }, [luaFunctionRef, pLuaMain](const bool & correct) {
299
- CLuaArguments arguments;
300
- arguments.PushBoolean (correct);
301
-
302
- arguments.Call (pLuaMain, luaFunctionRef);
302
+ }, [luaFunctionRef](const bool & correct) {
303
+ CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine (luaFunctionRef.GetLuaVM ());
304
+ if (pLuaMain)
305
+ {
306
+ CLuaArguments arguments;
307
+ arguments.PushBoolean (correct);
308
+ arguments.Call (pLuaMain, luaFunctionRef);
309
+ }
303
310
});
304
311
305
312
lua_pushboolean (luaVM, true );
0 commit comments