changeset 27776:492a3798f87c

- fix a bug accidentally introduced to msn plugin - add guard to sanitize_* and botch_*
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 29 Feb 2008 19:18:27 +0000
parents 43e0ad5bff97
children 2cb44870580d
files libpurple/protocols/msn/msg.c libpurple/protocols/msnp9/msg.c libpurple/util.c
diffstat 3 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c	Fri Feb 29 18:32:40 2008 +0000
+++ b/libpurple/protocols/msn/msg.c	Fri Feb 29 19:18:27 2008 +0000
@@ -537,7 +537,6 @@
 	gchar *ret = NULL;
 
 	g_return_val_if_fail(msg != NULL, NULL);
-	g_return_val_if_fail(len != NULL, NULL);
 
 	ret = sanitize_utf((gchar *)msg->body, msg->body_len, len);
 	return ret;
--- a/libpurple/protocols/msnp9/msg.c	Fri Feb 29 18:32:40 2008 +0000
+++ b/libpurple/protocols/msnp9/msg.c	Fri Feb 29 19:18:27 2008 +0000
@@ -540,7 +540,6 @@
 	gchar *ret = NULL;
 
 	g_return_val_if_fail(msg != NULL, NULL);
-	g_return_val_if_fail(len != NULL, NULL);
 
 	ret = sanitize_utf((gchar *)msg->body, msg->body_len, len);
 	return ret;
--- a/libpurple/util.c	Fri Feb 29 18:32:40 2008 +0000
+++ b/libpurple/util.c	Fri Feb 29 19:18:27 2008 +0000
@@ -4712,7 +4712,10 @@
 void botch_ucs(gchar *ucs_src, gsize len)
 {
 	gint i;
-    guchar *ucs = (guchar *)ucs_src;
+	guchar *ucs = (guchar *)ucs_src;
+
+	g_return_if_fail(ucs_src != NULL);
+	g_return_if_fail(len > 0);
 
  	for(i=0;i<len;i+=2){
  		switch(*(ucs+i)){
@@ -4766,6 +4769,9 @@
 	gint i;
 	guchar *ucs = (guchar *)ucs_src;
 
+	g_return_if_fail(ucs_src != NULL);
+	g_return_if_fail(len > 0);
+
 	for(i=0;i<len;i+=2){
 		switch(*(ucs+i)){
 		case 0x22:
@@ -4808,7 +4814,11 @@
 #ifdef _WIN32
 gchar *sanitize_utf(const gchar *msg, gsize len, gsize *newlen)
 {
+	g_retrun_val_if_fail(msg != NULL, NULL);
+	g_return_val_if_fail(len > 0, NULL);
+
 	*newlen = len;
+
 	return g_strndup(msg, len);
 }
 #else
@@ -4818,6 +4828,9 @@
 	size_t bytes;
 	guchar *utf;
 
+	g_return_val_if_fail(msg != NULL, NULL);
+	g_return_val_if_fail(len > 0, NULL);
+
 	utf = (guchar *)g_strndup(msg, len);
 
 	bytes = len;
@@ -4890,6 +4903,9 @@
  	int i,bytes;
 	unsigned char *utf;
 
+	g_return_val_if_fail(msg != NULL, NULL);
+	g_return_val_if_fail(len > 0, NULL);
+
 	bytes = len;
 
 	utf = g_malloc0(bytes*3/2+1); /* new length might be 3/2 in the worst case */