diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fe-text/irssi.c | 15 | ||||
-rw-r--r-- | src/perl/perl-common.c | 14 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index fbb3e0c1..d0bbbc99 100644 --- a/src/fe-text/irssi.c +++ b/src/fe-text/irssi.c @@ -309,6 +309,17 @@ static void winsock_init(void) } #endif +#ifdef HAVE_GC +#include <gc/gc.h> +GMemVTable gc_mem_table = { + GC_malloc, + GC_realloc, + GC_free, + + NULL, NULL, NULL +}; +#endif + int main(int argc, char **argv) { static struct poptOption options[] = { @@ -316,6 +327,10 @@ int main(int argc, char **argv) { NULL, '\0', 0, NULL } }; +#ifdef HAVE_GC + g_mem_set_vtable(&gc_mem_table); +#endif + dummy = FALSE; quitting = FALSE; core_init_paths(argc, argv); diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index d39d351c..f6c56552 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -43,6 +43,10 @@ #include "perl-core.h" #include "perl-common.h" +#ifdef HAVE_GC +# include <gc/gc.h> +#endif + typedef struct { char *stash; PERL_OBJECT_FUNC fill_func; @@ -151,6 +155,7 @@ void *irssi_ref_object(SV *o) { SV **sv; HV *hv; + void *p; hv = hvref(o); if (hv == NULL) @@ -158,8 +163,13 @@ void *irssi_ref_object(SV *o) sv = hv_fetch(hv, "_irssi", 6, 0); if (sv == NULL) - croak("variable is damaged"); - return GINT_TO_POINTER(SvIV(*sv)); + croak("variable is damaged"); + p = GINT_TO_POINTER(SvIV(*sv)); +#ifdef HAVE_GC + if (GC_base(p) == NULL) + croak("variable is already free'd"); +#endif + return p; } void irssi_add_object(int type, int chat_type, const char *stash, |