changeset 23653:6f47135f5378

Some cleanup and a couple leak fixes.
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 07 Aug 2008 01:41:44 +0000
parents 27eacd38c721
children b0812ce0ec17
files libpurple/plugins/perl/common/Account.xs libpurple/plugins/perl/common/AccountOpts.xs libpurple/plugins/perl/common/BuddyList.xs libpurple/plugins/perl/common/Conversation.xs libpurple/plugins/perl/common/PluginPref.xs libpurple/plugins/perl/common/Prefs.xs libpurple/plugins/perl/common/Roomlist.xs libpurple/plugins/perl/common/Server.xs libpurple/plugins/perl/common/Status.xs libpurple/plugins/perl/perl-common.c libpurple/plugins/perl/perl-handlers.c libpurple/plugins/perl/perl.c
diffstat 12 files changed, 86 insertions(+), 125 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/perl/common/Account.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/Account.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -107,10 +107,9 @@
     t_GL = NULL;
     t_len = av_len((AV *)SvRV(status_types));
 
-    for (i = 0; i < t_len; i++) {
-        STRLEN t_sl;
-        t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(status_types), i, 0), t_sl));
-    }
+    for (i = 0; i < t_len; i++)
+        t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(status_types), i, 0)));
+
     purple_account_set_status_types(account, t_GL);
 
 void
@@ -210,10 +209,9 @@
     t_GL = NULL;
     t_len = av_len((AV *)SvRV(list));
 
-    for (i = 0; i < t_len; i++) {
-        STRLEN t_sl;
-        t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(list), i, 0), t_sl));
-    }
+    for (i = 0; i < t_len; i++)
+        t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(list), i, 0)));
+
     purple_account_add_buddies(account, t_GL);
     g_list_free(t_GL);
 
@@ -240,18 +238,15 @@
     t_GL1 = NULL;
     t_len = av_len((AV *)SvRV(A));
 
-    for (i = 0; i < t_len; i++) {
-        STRLEN t_sl;
-        t_GL1 = g_list_append(t_GL1, SvPV(*av_fetch((AV *)SvRV(A), i, 0), t_sl));
-    }
+    for (i = 0; i < t_len; i++)
+        t_GL1 = g_list_append(t_GL1, SvPVutf8_nolen(*av_fetch((AV *)SvRV(A), i, 0)));
 
     t_GL2 = NULL;
     t_len = av_len((AV *)SvRV(B));
 
-    for (i = 0; i < t_len; i++) {
-        STRLEN t_sl;
-        t_GL2 = g_list_append(t_GL2, SvPV(*av_fetch((AV *)SvRV(B), i, 0), t_sl));
-    }
+    for (i = 0; i < t_len; i++)
+        t_GL2 = g_list_append(t_GL2, SvPVutf8_nolen(*av_fetch((AV *)SvRV(B), i, 0)));
+
     purple_account_remove_buddies(account, t_GL1, t_GL2);
     g_list_free(t_GL1);
     g_list_free(t_GL2);
--- a/libpurple/plugins/perl/common/AccountOpts.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/AccountOpts.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -44,10 +44,9 @@
 	t_GL = NULL;
 	t_len = av_len((AV *)SvRV(values));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(values), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(values), i, 0)));
+
 	RETVAL  = purple_account_option_list_new(text, pref_name, t_GL);
 OUTPUT:
 	RETVAL
@@ -133,10 +132,9 @@
 	t_GL = NULL;
 	t_len = av_len((AV *)SvRV(values));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(values), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(values), i, 0)));
+
 	purple_account_option_set_list(option, t_GL);
 
 void
--- a/libpurple/plugins/perl/common/BuddyList.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/BuddyList.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -362,7 +362,7 @@
 	for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
 		t_key = hv_iterkey(t_HE, &len);
 		t_SV = *hv_fetch(t_HV, t_key, len, 0);
-		t_value = SvPV(t_SV, PL_na);
+		t_value = SvPVutf8_nolen(t_SV);
 
 		g_hash_table_insert(t_GHash, t_key, t_value);
 	}
--- a/libpurple/plugins/perl/common/Conversation.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/Conversation.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -342,10 +342,8 @@
 	t_GL = NULL;
 	t_len = av_len((AV *)SvRV(users));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(users), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(users), i, 0)));
 
 	for (l = purple_conv_chat_set_users(chat, t_GL); l != NULL; l = l->next) {
 		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ListEntry")));
@@ -382,10 +380,8 @@
 	t_GL = NULL;
 	t_len = av_len((AV *)SvRV(ignored));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(ignored), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(ignored), i, 0)));
 
 	for (l = purple_conv_chat_set_ignored(chat, t_GL); l != NULL; l = l->next) {
 		XPUSHs(sv_2mortal(purple_perl_bless_object(l->data, "Purple::ListEntry")));
@@ -441,26 +437,20 @@
 	t_GL_users = NULL;
 	t_len = av_len((AV *)SvRV(users));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL_users = g_list_append(t_GL_users, SvPV(*av_fetch((AV *)SvRV(users), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL_users = g_list_append(t_GL_users, SvPVutf8_nolen(*av_fetch((AV *)SvRV(users), i, 0)));
 
 	t_GL_flags = NULL;
 	t_len = av_len((AV *)SvRV(flags));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL_flags = g_list_append(t_GL_flags, SvPV(*av_fetch((AV *)SvRV(flags), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL_flags = g_list_append(t_GL_flags, SvPVutf8_nolen(*av_fetch((AV *)SvRV(flags), i, 0)));
 
 	t_GL_extra_msgs = NULL;
 	t_len = av_len((AV *)SvRV(extra_msgs));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL_extra_msgs = g_list_append(t_GL_extra_msgs, SvPV(*av_fetch((AV *)SvRV(extra_msgs), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL_extra_msgs = g_list_append(t_GL_extra_msgs, SvPVutf8_nolen(*av_fetch((AV *)SvRV(extra_msgs), i, 0)));
 
 	purple_conv_chat_add_users(chat, t_GL_users, t_GL_extra_msgs, t_GL_flags, new_arrivals);
 
--- a/libpurple/plugins/perl/common/PluginPref.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/PluginPref.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -62,7 +62,7 @@
 	const char *label
 # Do the appropriate conversion based on the perl type specified.
 # Currently only Strings and Ints will work.
-	gpointer choice = (SvPOKp($arg) ? SvPV($arg, PL_na) : (SvIOKp($arg) ? GINT_TO_POINTER(SvIV($arg)) : NULL));
+	gpointer choice = (SvPOKp($arg) ? SvPVutf8_nolen($arg) : (SvIOKp($arg) ? GINT_TO_POINTER(SvIV($arg)) : NULL));
 
 void
 purple_plugin_pref_destroy(pref)
--- a/libpurple/plugins/perl/common/Prefs.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/Prefs.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -53,10 +53,9 @@
 	t_GL = NULL;
 	t_len = av_len((AV *)SvRV(value));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(value), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(value), i, 0)));
+
 	purple_prefs_add_string_list(name, t_GL);
 	g_list_free(t_GL);
 
@@ -171,10 +170,9 @@
 	t_GL = NULL;
 	t_len = av_len((AV *)SvRV(value));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(value), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(value), i, 0)));
+
 	purple_prefs_set_string_list(name, t_GL);
 	g_list_free(t_GL);
 
--- a/libpurple/plugins/perl/common/Roomlist.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/Roomlist.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -84,10 +84,9 @@
 	t_GL = NULL;
 	t_len = av_len((AV *)SvRV(fields));
 
-	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(fields), i, 0), t_sl));
-	}
+	for (i = 0; i < t_len; i++)
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(fields), i, 0)));
+
 	purple_roomlist_set_fields(list, t_GL);
 
 void 
--- a/libpurple/plugins/perl/common/Server.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/Server.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -85,7 +85,7 @@
 	for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
 		t_key = hv_iterkey(t_HE, &len);
 		t_SV = *hv_fetch(t_HV, t_key, len, 0);
- 		t_value = SvPV(t_SV, PL_na);
+ 		t_value = SvPVutf8_nolen(t_SV);
 
 		g_hash_table_insert(t_GHash, t_key, t_value);
 	}
@@ -140,7 +140,7 @@
 	for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
 		t_key = hv_iterkey(t_HE, &len);
 		t_SV = *hv_fetch(t_HV, t_key, len, 0);
- 		t_value = SvPV(t_SV, PL_na);
+ 		t_value = SvPVutf8_nolen(t_SV);
 
 		g_hash_table_insert(t_GHash, t_key, t_value);
 	}
@@ -170,7 +170,7 @@
 	for (t_HE = hv_iternext(t_HV); t_HE != NULL; t_HE = hv_iternext(t_HV) ) {
 		t_key = hv_iterkey(t_HE, &len);
 		t_SV = *hv_fetch(t_HV, t_key, len, 0);
- 		t_value = SvPV(t_SV, PL_na);
+ 		t_value = SvPVutf8_nolen(t_SV);
 
 		g_hash_table_insert(t_GHash, t_key, t_value);
 	}
--- a/libpurple/plugins/perl/common/Status.xs	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/common/Status.xs	Thu Aug 07 01:41:44 2008 +0000
@@ -86,8 +86,7 @@
 	t_len = av_len((AV *)SvRV(source_list));
 
 	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(source_list), i, 0), t_sl));
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(source_list), i, 0)));
 	}
 	purple_presence_add_list(presence, t_GL);
 	g_list_free(t_GL);
@@ -389,8 +388,7 @@
 	t_len = av_len((AV *)SvRV(status_types));
 
 	for (i = 0; i < t_len; i++) {
-		STRLEN t_sl;
-		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(status_types), i, 0), t_sl));
+		t_GL = g_list_append(t_GL, SvPVutf8_nolen(*av_fetch((AV *)SvRV(status_types), i, 0)));
 	}
 	RETVAL = (PurpleStatusType *)purple_status_type_find_with_id(t_GL, id);
 	g_list_free(t_GL);
--- a/libpurple/plugins/perl/perl-common.c	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/perl-common.c	Thu Aug 07 01:41:44 2008 +0000
@@ -176,7 +176,6 @@
 {
 	int count = 0, i, ret_value = 1;
 	SV *sv_args[argc];
-	STRLEN na;
 	dSP;
 	PERL_SET_CONTEXT(my_perl);
 	/*
@@ -207,7 +206,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug(PURPLE_DEBUG_ERROR, "perl",
 				   "Perl function %s exited abnormally: %s\n",
-				   function, SvPV(ERRSV, na));
+				   function, SvPVutf8_nolen(ERRSV));
 		(void)POPs;
 	} else if (count != 1) {
 		/*
@@ -235,7 +234,7 @@
 			 * of hackish.  I should fix it.  Look how long this comment is.
 			 * Holy crap.
 			 */
-			args[i] = g_strdup(SvPV(sv_args[i], na));
+			args[i] = g_strdup(SvPVutf8_nolen(sv_args[i]));
 		}
 	}
 
@@ -381,7 +380,6 @@
 void *
 purple_perl_data_from_sv(PurpleValue *value, SV *sv)
 {
-	STRLEN na;
 
 	switch (purple_value_get_type(value)) {
 		case PURPLE_TYPE_BOOLEAN: return (void *)SvIV(sv);
@@ -391,7 +389,7 @@
 		case PURPLE_TYPE_ULONG:   return (void *)SvUV(sv);
 		case PURPLE_TYPE_INT64:   return (void *)SvIV(sv);
 		case PURPLE_TYPE_UINT64:  return (void *)SvUV(sv);
-		case PURPLE_TYPE_STRING:  return g_strdup((void *)SvPV(sv, na));
+		case PURPLE_TYPE_STRING:  return g_strdup(SvPVutf8_nolen(sv));
 		case PURPLE_TYPE_POINTER: return (void *)SvIV(sv);
 		case PURPLE_TYPE_BOXED:   return (void *)SvIV(sv);
 
--- a/libpurple/plugins/perl/perl-handlers.c	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/perl-handlers.c	Thu Aug 07 01:41:44 2008 +0000
@@ -23,7 +23,6 @@
 	gchar *hvname;
 	PurplePlugin *plugin;
 	PurplePerlScript *gps;
-	STRLEN na;
 	dSP;
 
 	plugin = action->plugin;
@@ -54,7 +53,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl plugin action function exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	PUTBACK;
@@ -68,7 +67,6 @@
 	GList *l = NULL;
 	PurplePerlScript *gps;
 	int i = 0, count = 0;
-	STRLEN na;
 	dSP;
 
 	gps = plugin->info->extra_info;
@@ -94,7 +92,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl plugin actions lookup exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	if (count == 0)
@@ -102,14 +100,10 @@
 
 	for (i = 0; i < count; i++) {
 		SV *sv;
-		gchar *label;
-		PurplePluginAction *act = NULL;
+		PurplePluginAction *act;
 
 		sv = POPs;
-		label = SvPV_nolen(sv);
-		/* XXX I think this leaks, but doing it without the strdup
-		 * just showed garbage */
-		act = purple_plugin_action_new(g_strdup(label), purple_perl_plugin_action_cb);
+		act = purple_plugin_action_new(SvPVutf8_nolen(sv), purple_perl_plugin_action_cb);
 		l = g_list_prepend(l, act);
 	}
 
@@ -129,7 +123,6 @@
 	MAGIC *mg;
 	GtkWidget *ret;
 	PurplePerlScript *gps;
-	STRLEN na;
 	dSP;
 
 	gps = plugin->info->extra_info;
@@ -147,7 +140,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl gtk plugin frame init exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	/* We have a Gtk2::Frame on top of the stack */
@@ -173,7 +166,6 @@
 	int count;
 	PurplePerlScript *gps;
 	PurplePluginPrefFrame *ret_frame;
-	STRLEN na;
 	dSP;
 
 	gps = (PurplePerlScript *)plugin->info->extra_info;
@@ -192,7 +184,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl plugin prefs frame init exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	if (count != 1)
@@ -249,7 +241,6 @@
 {
 	PurplePerlTimeoutHandler *handler = data;
 	gboolean ret = FALSE;
-	STRLEN na;
 
 	dSP;
 	ENTER;
@@ -263,7 +254,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl timeout function exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	ret = POPi;
@@ -291,7 +282,6 @@
 	PurpleValue *ret_value, **values;
 	SV **sv_args;
 	DATATYPE **copy_args;
-	STRLEN na;
 
 	dSP;
 	ENTER;
@@ -334,7 +324,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl function exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	/* See if any parameters changed. */
@@ -373,14 +363,13 @@
 					if (strcmp(*((char **)copy_args[i]), SvPVX(sv_args[i]))) {
 						g_free(*((char **)copy_args[i]));
 						*((char **)copy_args[i]) =
-							g_strdup(SvPV(sv_args[i], na));
+							g_strdup(SvPVutf8_nolen(sv_args[i]));
 					}
+					/* Clean up sv_args[i] - we're done with it */
+					sv_2mortal(sv_args[i]);
 					break;
 
 				case PURPLE_TYPE_POINTER:
-					*((void **)copy_args[i]) = (void *)SvIV(sv_args[i]);
-					break;
-
 				case PURPLE_TYPE_BOXED:
 					*((void **)copy_args[i]) = (void *)SvIV(sv_args[i]);
 					break;
@@ -392,6 +381,7 @@
 					break;
 			}
 
+
 #if 0
 			*((void **)copy_args[i]) = purple_perl_data_from_sv(values[i],
 															  sv_args[i]);
@@ -564,7 +554,6 @@
             gchar **args, gchar **error, void *data)
 {
 	int i = 0, count, ret_value = PURPLE_CMD_RET_OK;
-	STRLEN na;
 	SV *cmdSV, *tmpSV, *convSV;
 	PurplePerlCmdHandler *handler = data;
 
@@ -604,7 +593,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl plugin command function exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	SPAGAIN;
@@ -718,7 +707,6 @@
 			 gpointer data)
 {
 	PurplePerlPrefsHandler *handler = data;
-	STRLEN na;
 
 	dSP;
 	ENTER;
@@ -767,7 +755,7 @@
 	if (SvTRUE(ERRSV)) {
 		purple_debug_error("perl",
 		                 "Perl prefs callback function exited abnormally: %s\n",
-		                 SvPV(ERRSV, na));
+		                 SvPVutf8_nolen(ERRSV));
 	}
 
 	PUTBACK;
--- a/libpurple/plugins/perl/perl.c	Thu Aug 07 01:08:37 2008 +0000
+++ b/libpurple/plugins/perl/perl.c	Thu Aug 07 01:41:44 2008 +0000
@@ -288,24 +288,24 @@
 	ret = perl_parse(prober, xs_init, argc, argv, NULL);
 
 	if (ret != 0) {
-		STRLEN len;
 		const char * errmsg = "Unknown error";
 		if (SvTRUE(ERRSV))
-			errmsg = SvPV(ERRSV, len);
+			errmsg = SvPVutf8_nolen(ERRSV);
 		purple_debug_error("perl", "Unable to parse plugin %s (%d:%s)\n",
 						   plugin->path, ret, errmsg);
+		status = FALSE;
 		goto cleanup;
 	}
 
 	ret = perl_run(prober);
 
 	if (ret != 0) {
-		STRLEN len;
 		const char * errmsg = "Unknown error";
 		if (SvTRUE(ERRSV))
-			errmsg = SvPV(ERRSV, len);
+			errmsg = SvPVutf8_nolen(ERRSV);
 		purple_debug_error("perl", "Unable to run perl interpreter on plugin %s (%d:%s)\n",
 						   plugin->path, ret, errmsg);
+		status = FALSE;
 		goto cleanup;
 	}
 
@@ -335,7 +335,6 @@
 			PurplePluginInfo *info;
 			PurplePerlScript *gps;
 			char *basename;
-			STRLEN len;
 
 			info = g_new0(PurplePluginInfo, 1);
 			gps  = g_new0(PurplePerlScript, 1);
@@ -358,9 +357,9 @@
 
 			/* We know this one exists. */
 			key = hv_fetch(plugin_info, "name", strlen("name"), 0);
-			info->name = g_strdup(SvPV(*key, len));
+			info->name = g_strdup(SvPVutf8_nolen(*key));
 			/* Set id here in case we don't find one later. */
-			info->id = g_strdup(SvPV(*key, len));
+			info->id = g_strdup(info->name);
 
 #ifdef PURPLE_GTKPERL
 			if ((key = hv_fetch(plugin_info, "GTK_UI",
@@ -370,40 +369,40 @@
 
 			if ((key = hv_fetch(plugin_info, "url",
 			                    strlen("url"), 0)))
-				info->homepage = g_strdup(SvPV(*key, len));
+				info->homepage = g_strdup(SvPVutf8_nolen(*key));
 
 			if ((key = hv_fetch(plugin_info, "author",
 			                    strlen("author"), 0)))
-				info->author = g_strdup(SvPV(*key, len));
+				info->author = g_strdup(SvPVutf8_nolen(*key));
 
 			if ((key = hv_fetch(plugin_info, "summary",
 			                    strlen("summary"), 0)))
-				info->summary = g_strdup(SvPV(*key, len));
+				info->summary = g_strdup(SvPVutf8_nolen(*key));
 
 			if ((key = hv_fetch(plugin_info, "description",
 			                    strlen("description"), 0)))
-				info->description = g_strdup(SvPV(*key, len));
+				info->description = g_strdup(SvPVutf8_nolen(*key));
 
 			if ((key = hv_fetch(plugin_info, "version",
 			                    strlen("version"), 0)))
-				info->version = g_strdup(SvPV(*key, len));
+				info->version = g_strdup(SvPVutf8_nolen(*key));
 
 			/* We know this one exists. */
 			key = hv_fetch(plugin_info, "load", strlen("load"), 0);
 			gps->load_sub = g_strdup_printf("%s::%s", gps->package,
-			                                SvPV(*key, len));
+			                                SvPVutf8_nolen(*key));
 
 			if ((key = hv_fetch(plugin_info, "unload",
 			                    strlen("unload"), 0)))
 				gps->unload_sub = g_strdup_printf("%s::%s",
 				                                  gps->package,
-				                                  SvPV(*key, len));
+				                                  SvPVutf8_nolen(*key));
 
 			if ((key = hv_fetch(plugin_info, "id",
 			                    strlen("id"), 0))) {
 				g_free(info->id);
 				info->id = g_strdup_printf("perl-%s",
-				                           SvPV(*key, len));
+				                           SvPVutf8_nolen(*key));
 			}
 
 		/********************************************************/
@@ -424,7 +423,7 @@
 				 * will create a frame for us */
 				gps->prefs_sub = g_strdup_printf("%s::%s",
 				                                 gps->package,
-				                                 SvPV(*key, len));
+				                                 SvPVutf8_nolen(*key));
 				info->prefs_info = &ui_info;
 			}
 
@@ -435,7 +434,7 @@
 				 * will create a frame for us */
 				gps->gtk_prefs_sub = g_strdup_printf("%s::%s",
 				                                     gps->package,
-				                                     SvPV(*key, len));
+				                                     SvPVutf8_nolen(*key));
 				info->ui_info = &gtk_ui_info;
 			}
 #endif
@@ -444,7 +443,7 @@
 			                    strlen("plugin_action_sub"), 0))) {
 				gps->plugin_action_sub = g_strdup_printf("%s::%s",
 				                                         gps->package,
-				                                         SvPV(*key, len));
+				                                         SvPVutf8_nolen(*key));
 				info->actions = purple_perl_plugin_actions;
 			}
 
@@ -499,11 +498,9 @@
 		SPAGAIN;
 
 		if (SvTRUE(ERRSV)) {
-			STRLEN len;
-
 			purple_debug(PURPLE_DEBUG_ERROR, "perl",
 			           "Perl function %s exited abnormally: %s\n",
-			           gps->load_sub, SvPV(ERRSV, len));
+			           gps->load_sub, SvPVutf8_nolen(ERRSV));
 		}
 
 		PUTBACK;
@@ -525,7 +522,7 @@
 	SAVETMPS;
 
 	PUSHMARK(SP);
-	XPUSHs(sv_2mortal(newSVpv(package, strlen(package))));
+	XPUSHs(sv_2mortal(newSVpv(package, 0)));
 	PUTBACK;
 
 	perl_call_pv("Purple::PerlLoader::destroy_package",
@@ -563,11 +560,9 @@
 		SPAGAIN;
 
 		if (SvTRUE(ERRSV)) {
-			STRLEN len;
-
 			purple_debug(PURPLE_DEBUG_ERROR, "perl",
 			           "Perl function %s exited abnormally: %s\n",
-			           gps->load_sub, SvPV(ERRSV, len));
+			           gps->unload_sub, SvPVutf8_nolen(ERRSV));
 		}
 
 		PUTBACK;
@@ -592,21 +587,23 @@
 		PurplePerlScript *gps;
 
 		g_free(plugin->info->name);
-		g_free(plugin->info->version);
+		g_free(plugin->info->id);
+		g_free(plugin->info->homepage);
+		g_free(plugin->info->author);
 		g_free(plugin->info->summary);
 		g_free(plugin->info->description);
-		g_free(plugin->info->author);
-		g_free(plugin->info->homepage);
+		g_free(plugin->info->version);
 
 		gps = (PurplePerlScript *)plugin->info->extra_info;
 		if (gps != NULL) {
+			g_free(gps->package);
 			g_free(gps->load_sub);
 			g_free(gps->unload_sub);
-			g_free(gps->package);
 			g_free(gps->prefs_sub);
 #ifdef PURPLE_GTKPERL
 			g_free(gps->gtk_prefs_sub);
 #endif
+			g_free(gps->plugin_action_sub);
 			g_free(gps);
 			plugin->info->extra_info = NULL;
 		}