Correctly clear observer reference on the observed object when it is freed.

[INTERPRETER]
* BUG: Correctly clear observer reference on the observed object when it is freed.
* BUG: Clear environment variables set by the interpreter, as they can be read by the shared libraries exit routines after main() has been terminated.
This commit is contained in:
gambas 2018-12-24 17:57:36 +01:00
parent 76a15e14ff
commit bfc88545c8
3 changed files with 19 additions and 4 deletions

View file

@ -47,7 +47,7 @@ void COBSERVER_attach(COBSERVER *this, void *parent, const char *name)
#if DEBUG_ME
fprintf(stderr, "COBSERVER_attach: %p: %s %p\n", this, parent ? OBJECT_class(parent)->name : "", parent);
#endif
if (this->event)
if (this->object && this->event)
EVENT_search(OBJECT_class(this->object), this->event, name, parent);
}

View file

@ -602,11 +602,25 @@ void LOCAL_init(void)
void LOCAL_exit(void)
{
STRING_free(&env_LANG);
STRING_free(&env_LC_ALL);
STRING_free(&env_LANGUAGE);
if (env_LANG)
{
unsetenv("LANG");
STRING_free(&env_LANG);
}
if (env_LC_ALL)
{
unsetenv("LC_ALL");
STRING_free(&env_LC_ALL);
}
if (env_LANGUAGE)
{
unsetenv("LANGUAGE");
STRING_free(&env_LANGUAGE);
}
if (!LOCAL_is_UTF8)
STRING_free(&LOCAL_encoding);
STRING_free(&_lang);
free_local_info();
}

View file

@ -196,6 +196,7 @@ static void remove_observers(OBJECT *ob)
#if DEBUG_EVENT
fprintf(stderr, "Remove observer %p %d: %p: %p\n", obs, (int)obs->ob.ref, ob, obs->object);
#endif
obs->object = NULL;
OBJECT_UNREF(obs);
obs = next;
}