diff libpurple/protocols/qq/utils.c @ 24144:a95c7e71064c

2008.10.05 - ccpaging <ccpagint(at)gmail.com> * Add my uid into buddy list * Fixed a minor bug in qq_create_buddy. Not get new buddy's info. * There are 38 fields in protocol 2008, one more than 2005/2007. * The packet of Modifing buddy info is changed. Need sample to fix it.
author SHiNE CsyFeK <csyfek@gmail.com>
date Wed, 22 Oct 2008 14:48:46 +0000
parents df699d739b8f
children ec3f7d3e0445
line wrap: on
line diff
--- a/libpurple/protocols/qq/utils.c	Wed Oct 22 14:47:39 2008 +0000
+++ b/libpurple/protocols/qq/utils.c	Wed Oct 22 14:48:46 2008 +0000
@@ -104,7 +104,7 @@
 {
 	guint8 *input;
 	gchar **segments;
-	gint i, j;
+	gint count, j;
 
 	g_return_val_if_fail(data != NULL && len != 0 && delimit != 0, NULL);
 
@@ -118,22 +118,18 @@
 	if (expected_fields <= 0)
 		return segments;
 
-	for (i = 0; segments[i] != NULL; i++) {;
+	for (count = 0; segments[count] != NULL; count++) {;
 	}
-	if (i < expected_fields) {	/* not enough fields */
-		purple_debug_error("QQ", "Invalid data, expect %d fields, found only %d, discard\n",
-				expected_fields, i);
-		g_strfreev(segments);
+	if (count < expected_fields) {	/* not enough fields */
+		purple_debug_error("QQ", "Less fields %d then %d\n", count, expected_fields);
 		return NULL;
-	} else if (i > expected_fields) {	/* more fields, OK */
-		purple_debug_warning("QQ", "Dangerous data, expect %d fields, found %d, return all\n",
-				expected_fields, i);
+	} else if (count > expected_fields) {	/* more fields, OK */
+		purple_debug_warning("QQ", "More fields %d than %d\n", count, expected_fields);
 		/* free up those not used */
-		for (j = expected_fields; j < i; j++) {
+		for (j = expected_fields; j < count; j++) {
 			purple_debug_warning("QQ", "field[%d] is %s\n", j, segments[j]);
 			g_free(segments[j]);
 		}
-
 		segments[expected_fields] = NULL;
 	}
 
@@ -197,7 +193,7 @@
 	g_return_val_if_fail(start != NULL, NULL);
 	end = strchr(start, ')');
 	g_return_val_if_fail(end != NULL && (end - start) > 1, NULL);
-	
+
 	ret = g_strndup(start + 1, end - start - 1);
 
 	return ret;