summaryrefslogtreecommitdiff
path: root/src/perl
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-12-23 06:06:14 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-12-23 06:06:14 +0000
commitcdc52b773e09ab0c0a650fdd06c4e20cb5b90e15 (patch)
treedab1519f57b130fc16c67ffc042e82c3afd9f429 /src/perl
parent495501c284e35d02e8be1586d941920a12d0a1d7 (diff)
downloadirssi-cdc52b773e09ab0c0a650fdd06c4e20cb5b90e15.zip
--with-gc enables now support for Boehm's GC, if it's found and glib2 is
used. This also enables an extra check for perl library to verify scripts aren't using objects that have already been free'd - while not a fully safe solution it's much better than before :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3063 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/perl')
-rw-r--r--src/perl/perl-common.c14
1 files changed, 12 insertions, 2 deletions
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,