Merge pull request #277 from szdytom/fix-some-leak

Fix memory leaks
This commit is contained in:
BLUELOVETH 2024-06-19 11:20:52 +08:00 committed by GitHub
commit f06f7e21c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -101,6 +101,7 @@ Error* Compiler::pop_context() noexcept{
assert(func->type != FuncType::UNSET);
}
contexts.back().s_clean();
contexts.pop_back();
return NULL;
}

View File

@ -583,7 +583,6 @@ PyVar VM::__py_exec_internal(const CodeObject_& code, PyVar globals, PyVar local
check_compatible_type(globals, VM::tp_dict);
// make a temporary object and copy globals into it
globals_obj = new_object<DummyInstance>(VM::tp_object).get();
globals_obj->_attr = new NameDict();
globals_dict = &PK_OBJ_GET(Dict, globals);
globals_dict->apply([&](PyVar k, PyVar v) {
globals_obj->attr().set(CAST(Str&, k), v);
@ -1893,6 +1892,8 @@ void ManagedHeap::mark() {
void ManagedHeap::_delete(PyObject* obj) {
const PyTypeInfo* ti = vm->_tp_info(obj->type);
if(ti->vt._dtor) ti->vt._dtor(obj->_value_ptr());
if (obj->_attr)
c11_vector__dtor(obj->_attr);
delete obj->_attr; // delete __dict__ if exists
if(obj->gc_is_large){
std::free(obj);