changeset 26880:22b87a82755b

Fix a couple of crashes in the perl plugin loader. * Do NULL check before using strcmp. The NULL could be set by either libpurple, or the plugin. * Looks like we need to PERL_SET_CONTEXT to setup the perl environment correctly.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 16 May 2009 18:33:55 +0000
parents 7c58f6f50f16
children 795606e2f7c6
files libpurple/plugins/perl/perl-handlers.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/perl/perl-handlers.c	Sat May 16 17:11:50 2009 +0000
+++ b/libpurple/plugins/perl/perl-handlers.c	Sat May 16 18:33:55 2009 +0000
@@ -284,6 +284,8 @@
 	DATATYPE **copy_args;
 
 	dSP;
+	PERL_SET_CONTEXT(my_perl);
+	SPAGAIN;
 	ENTER;
 	SAVETMPS;
 	PUSHMARK(sp);
@@ -364,7 +366,8 @@
 					break;
 
 				case PURPLE_TYPE_STRING:
-					if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) {
+					if (!*((char **)copy_args[i]) || !SvPVX(sv_args[i]) ||
+							strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) {
 						g_free(*((char **)copy_args[i]));
 						*((char **)copy_args[i]) =
 							g_strdup(SvPVutf8_nolen(sv_args[i]));