MCPcopy Create free account
hub / github.com/defold/defold / CanUnpackLuaBuffer

Function CanUnpackLuaBuffer

engine/gamesys/src/gamesys/scripts/script_buffer.cpp:137–145  ·  view source on GitHub ↗

Unless we check that a buffer resource actually exists, the engine will crash when unpacking. This can happen if a user destroys a resource but a LuaHBuffer still holds a reference to the resource

Source from the content-addressed store, hash-verified

135 // Unless we check that a buffer resource actually exists, the engine will crash
136 // when unpacking. This can happen if a user destroys a resource but a LuaHBuffer still holds a reference to the resource
137 static bool CanUnpackLuaBuffer(dmScript::LuaHBuffer* lua_buffer)
138 {
139 if (lua_buffer->m_Owner == dmScript::OWNER_RES)
140 {
141 uint64_t hash;
142 return dmResource::RESULT_OK == dmResource::GetPath(g_Factory, lua_buffer->m_BufferRes, &hash);
143 }
144 return true;
145 }
146
147 static bool IsStream(lua_State *L, int index)
148 {

Callers 1

Calls 1

GetPathFunction · 0.50

Tested by

no test coverage detected