2006-09-01 Mikael Hallendal <micke@imendio.com>
authorhallski <hallski>
Fri, 01 Sep 2006 14:01:48 +0000
changeset 168 ac1affcd5d22
parent 167 7bcccfa734e2
child 169 10bcf8e0e443
2006-09-01 Mikael Hallendal <micke@imendio.com> * loudmouth/lm-connection.c: (lm_connection_new_with_context), (lm_connection_send_raw): * loudmouth/lm-message-handler.c: (lm_message_handler_new), (lm_message_handler_is_valid): * loudmouth/lm-message-node.c: (lm_message_node_add_child), (lm_message_node_set_attribute), (lm_message_node_get_attribute), (lm_message_node_get_child), (lm_message_node_find_child): * loudmouth/lm-parser.c: * loudmouth/lm-utils.c: (_lm_utils_hostname_to_punycode), (lm_utils_get_localtime): - Patch from Martyn to add argument checks all around.
ChangeLog
loudmouth/lm-connection.c
loudmouth/lm-message-handler.c
loudmouth/lm-message-node.c
loudmouth/lm-parser.c
loudmouth/lm-utils.c
--- a/ChangeLog	Tue Aug 22 23:33:06 2006 +0000
+++ b/ChangeLog	Fri Sep 01 14:01:48 2006 +0000
@@ -1,3 +1,17 @@
+2006-09-01  Mikael Hallendal  <micke@imendio.com>
+
+	* loudmouth/lm-connection.c: (lm_connection_new_with_context),
+	(lm_connection_send_raw):
+	* loudmouth/lm-message-handler.c: (lm_message_handler_new),
+	(lm_message_handler_is_valid):
+	* loudmouth/lm-message-node.c: (lm_message_node_add_child),
+	(lm_message_node_set_attribute), (lm_message_node_get_attribute),
+	(lm_message_node_get_child), (lm_message_node_find_child):
+	* loudmouth/lm-parser.c:
+	* loudmouth/lm-utils.c: (_lm_utils_hostname_to_punycode),
+	(lm_utils_get_localtime):
+	- Patch from Martyn to add argument checks all around.
+
 2006-08-23  Martyn Russell  <martyn@imendio.com>
 
 	* examples/lm-send-async.c:
--- a/loudmouth/lm-connection.c	Tue Aug 22 23:33:06 2006 +0000
+++ b/loudmouth/lm-connection.c	Fri Sep 01 14:01:48 2006 +0000
@@ -1514,7 +1514,9 @@
 	connection = lm_connection_new (server);
 	connection->context = context;
 
-        g_main_context_ref (connection->context);
+	if (context) {
+        	g_main_context_ref (connection->context);
+	}
 
 	return connection;
 }
@@ -2323,6 +2325,7 @@
 			GError       **error)
 {
 	g_return_val_if_fail (connection != NULL, FALSE);
+	g_return_val_if_fail (str != NULL, FALSE);
 
 	return connection_send (connection, str, -1, error);
 }
--- a/loudmouth/lm-message-handler.c	Tue Aug 22 23:33:06 2006 +0000
+++ b/loudmouth/lm-message-handler.c	Fri Sep 01 14:01:48 2006 +0000
@@ -71,6 +71,8 @@
                         GDestroyNotify          notify)
 {
         LmMessageHandler *handler;
+
+	g_return_val_if_fail (function != NULL, NULL);
         
         handler = g_new0 (LmMessageHandler, 1);
         
@@ -110,6 +112,8 @@
 gboolean
 lm_message_handler_is_valid (LmMessageHandler *handler)
 {
+	g_return_val_if_fail (handler != NULL, FALSE);
+
 	return handler->valid;
 }
 
--- a/loudmouth/lm-message-node.c	Tue Aug 22 23:33:06 2006 +0000
+++ b/loudmouth/lm-message-node.c	Fri Sep 01 14:01:48 2006 +0000
@@ -177,6 +177,9 @@
 {
 	LmMessageNode *child;
 	
+        g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (name != NULL, NULL);
+
 	child = _lm_message_node_new (name);
 
 	lm_message_node_set_value (child, value);
@@ -234,6 +237,10 @@
 	gboolean  found = FALSE; 
 	GSList   *l;
 
+        g_return_if_fail (node != NULL);
+        g_return_if_fail (name != NULL);
+        g_return_if_fail (value != NULL);
+
 	for (l = node->attributes; l; l = l->next) {
 		KeyValuePair *kvp = (KeyValuePair *) l->data;
                 
@@ -272,6 +279,7 @@
         const gchar *ret_val = NULL;
 
         g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (name != NULL, NULL);
 
         for (l = node->attributes; l; l = l->next) {
                 KeyValuePair *kvp = (KeyValuePair *) l->data;
@@ -298,7 +306,10 @@
 lm_message_node_get_child (LmMessageNode *node, const gchar *child_name)
 {
 	LmMessageNode *l;
-	
+
+        g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (child_name != NULL, NULL);
+
 	for (l = node->children; l; l = l->next) {
 		if (strcmp (l->name, child_name) == 0) {
 			return l;
@@ -325,6 +336,9 @@
         LmMessageNode *l;
         LmMessageNode *ret_val = NULL;
 
+        g_return_val_if_fail (node != NULL, NULL);
+        g_return_val_if_fail (child_name != NULL, NULL);
+
         for (l = node->children; l; l = l->next) {
                 if (strcmp (l->name, child_name) == 0) {
                         return l;
--- a/loudmouth/lm-parser.c	Tue Aug 22 23:33:06 2006 +0000
+++ b/loudmouth/lm-parser.c	Fri Sep 01 14:01:48 2006 +0000
@@ -21,6 +21,8 @@
 #include <config.h>
 #include <string.h>
 
+#include <glib.h>
+
 #include "lm-debug.h"
 #include "lm-internals.h"
 #include "lm-message-node.h"
--- a/loudmouth/lm-utils.c	Tue Aug 22 23:33:06 2006 +0000
+++ b/loudmouth/lm-utils.c	Fri Sep 01 14:01:48 2006 +0000
@@ -166,13 +166,17 @@
 #else
 	return g_strdup(hostname);
 #endif
-}struct tm *
+}
+
+struct tm *
 lm_utils_get_localtime (const gchar *stamp)
 {
 	struct tm tm;
 	time_t    t;
 	gint      year, month;
 	
+	g_return_val_if_fail (stamp != NULL, NULL);
+
 	/* 20021209T23:51:30 */
 
 	sscanf (stamp, "%4d%2d%2dT%2d:%2d:%2d",