bonobo-activation (/oafd) bug



	A fix for a silly bug, appropriate for HEAD bonobo-activation and oafd.

	Dave, while we wait for this to get committed, you just need to add
some 'type="string"' tags to the document-manager.server file.

	May I commit ?

		Michael.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo-activation/ChangeLog,v
retrieving revision 1.261
diff -u -p -u -r1.261 ChangeLog
--- ChangeLog	2002/01/25 19:28:44	1.261
+++ ChangeLog	2002/01/31 02:53:58
@@ -1,3 +1,13 @@
+2002-01-31  Michael Meeks  <michael ximian com>
+
+	* test/broken.server: add a test attribute to break the
+	old server.
+
+	* server/object-directory-load.c (od_entry_read_props):
+	accelerate rough calc. of valid entry count. ensure that
+	if an invalid entry is encountered we don't leave blank
+	entries in the props array to segv us later.
+
 2002-01-25  Alexander Shopov  <al_shopov web bg>
 
 	* configure.in (ALL_LINGUAS): Added "bg" (Bulgarian).
Index: server/object-directory-load.c
===================================================================
RCS file: /cvs/gnome/bonobo-activation/server/object-directory-load.c,v
retrieving revision 1.29
diff -u -p -u -r1.29 object-directory-load.c
--- server/object-directory-load.c	2002/01/25 17:12:23	1.29
+++ server/object-directory-load.c	2002/01/31 02:53:59
@@ -41,31 +41,34 @@ static gboolean od_filename_has_extensio
 static void
 od_entry_read_props (Bonobo_ServerInfo *server, xmlNodePtr node)
 {
-	int i, n;
+	int i, max;
 	xmlNodePtr sub;
 	Bonobo_ActivationProperty *curprop;
 
-	for (n = 0, sub = node->xmlChildrenNode; sub; sub = sub->next) {
-		if (sub->type != XML_ELEMENT_NODE) {
+	for (max = 0, sub = node->xmlChildrenNode; sub; sub = sub->next) {
+		if (sub->type != XML_ELEMENT_NODE || sub->name == NULL) {
 			continue;
                 }
 
-		if (g_ascii_strcasecmp (sub->name, "oaf_attribute") != 0 &&
-                    g_ascii_strcasecmp (sub->name, "oaf_property") != 0) {
-			continue;
+		if (sub->name[0] != 'o' && sub->name [0] != 'O') {
+                        continue;
                 }
                 
-		n++;
+		max++;
 	}
 
-	server->props._length = n;
-	server->props._buffer = g_new0 (Bonobo_ActivationProperty, n);
+	server->props._buffer = g_new0 (Bonobo_ActivationProperty, max);
 
         curprop = server->props._buffer;
 
-	for (i = 0, sub = node->xmlChildrenNode; i < n; sub = sub->next, i++) {
+	for (i = 0, sub = node->xmlChildrenNode; sub != NULL && (i < max);
+             sub = sub->next) {
 		char *type, *valuestr;
 
+		if (sub->type != XML_ELEMENT_NODE || sub->name == NULL) {
+                        continue;
+                }
+
 		type = xmlGetProp (sub, "type");
 		if (type == NULL) {
 			continue;
@@ -156,8 +159,11 @@ od_entry_read_props (Bonobo_ServerInfo *
                 
 		free (type);
                 
+                i++;
 		curprop++;
 	}
+
+	server->props._length = i;
 }
 
 static char *
Index: test/broken.server
===================================================================
RCS file: /cvs/gnome/bonobo-activation/test/broken.server,v
retrieving revision 1.6
diff -u -p -u -r1.6 broken.server
--- test/broken.server	2001/08/01 22:01:40	1.6
+++ test/broken.server	2002/01/31 02:53:59
@@ -2,6 +2,7 @@
 
 <oaf_server iid="OAFIID:NotInServer:20000717" type="exe"
 	location="./bonobo-activation-empty-server">
+	<oaf_attribute noname="not a name" notype="not a type" novalue="no value"/>
 </oaf_server>
 
 <oaf_server iid="OAFIID:Bogus:20000526" type="factory"

-- 
 mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]