/pidgin/main: c10f36e28024: Fix Coverity CID 732167 (missing va_...

Daniel Atallah datallah at pidgin.im
Mon Oct 8 23:56:36 EDT 2012


Changeset: c10f36e280240b5e8dbc28d85d98983a481c799e
Author:	 Daniel Atallah <datallah at pidgin.im>
Date:	 2012-10-08 23:54 -0400
Branch:	 release-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/c10f36e28024

Description:

Fix Coverity CID 732167 (missing va_end in oscar.c:purple_parse_clientauto)

 * also refactor sloppy code to resolve CIDs 732165 and 732166

diffstat:

 libpurple/protocols/myspace/message.c |  14 ++++++++------
 libpurple/protocols/oscar/oscar.c     |   7 ++++---
 2 files changed, 12 insertions(+), 9 deletions(-)

diffs (84 lines):

diff --git a/libpurple/protocols/myspace/message.c b/libpurple/protocols/myspace/message.c
--- a/libpurple/protocols/myspace/message.c
+++ b/libpurple/protocols/myspace/message.c
@@ -129,7 +129,7 @@ msim_unescape(const gchar *msg)
  *
  * @param first_key The first argument (a key), or NULL to take all arguments
  *    from argp.
- * @param argp A va_list of variadic arguments, already started with va_start(). Will be va_end()'d.
+ * @param argp A va_list of variadic arguments, already started with va_start().
  * @return New MsimMessage *, must be freed with msim_msg_free().
  *
  * For internal use - users probably want msim_msg_new() or msim_send().
@@ -211,7 +211,6 @@ msim_msg_new_v(gchar *first_key, va_list
 				break;
 		}
 	} while(key);
-	va_end(argp);
 
 	return msg;
 }
@@ -227,14 +226,16 @@ msim_msg_new_v(gchar *first_key, va_list
 MsimMessage *
 msim_msg_new(gchar *first_key, ...)
 {
+	MsimMessage *ret = NULL;
 	va_list argp;
 
 	if (first_key) {
-	va_start(argp, first_key);
-		return msim_msg_new_v(first_key, argp);
-	} else {
-		return NULL;
+		va_start(argp, first_key);
+		ret = msim_msg_new_v(first_key, argp);
+		va_end(argp);
 	}
+
+	return ret;
 }
 
 /**
@@ -960,6 +961,7 @@ msim_send(MsimSession *session, ...)
 
 	va_start(argp, session);
 	msg = msim_msg_new_v(NULL, argp);
+	va_end(argp);
 
 	/* Actually send the message. */
 	success = msim_msg_send(session, msg);
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -2342,6 +2342,7 @@ static int purple_parse_clientauto(Oscar
 	va_list ap;
 	guint16 chan, reason;
 	char *who;
+	int ret = 1;
 
 	va_start(ap, fr);
 	chan = (guint16)va_arg(ap, unsigned int);
@@ -2350,7 +2351,7 @@ static int purple_parse_clientauto(Oscar
 
 	if (chan == 0x0002) { /* File transfer declined */
 		guchar *cookie = va_arg(ap, guchar *);
-		return purple_parse_clientauto_ch2(od, who, reason, cookie);
+		ret = purple_parse_clientauto_ch2(od, who, reason, cookie);
 	} else if (chan == 0x0004) { /* ICQ message */
 		guint32 state = 0;
 		char *msg = NULL;
@@ -2358,12 +2359,12 @@ static int purple_parse_clientauto(Oscar
 			state = va_arg(ap, guint32);
 			msg = va_arg(ap, char *);
 		}
-		return purple_parse_clientauto_ch4(od, who, reason, state, msg);
+		ret = purple_parse_clientauto_ch4(od, who, reason, state, msg);
 	}
 
 	va_end(ap);
 
-	return 1;
+	return ret;
 }
 
 static int purple_parse_genericerr(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {



More information about the Commits mailing list