libmimedir: altrep functionality

"Neal H. Walfield" <[email protected]>
Newsgroups gmane.comp.handhelds.gpe
Message-ID <87slmar3fr.wl%[email protected]>
Hi Sebastian,

I've found two bugs in libmimedir (0.3.1) involving a location's
alternate representation.

The first is that we need to also check if P->VALUE is not NULL in
mimedir_attribute_get_parameter_value (i.e. the file specifies an
empty list).

Second, mimedir_vcomponent_set_location allegedly allows URI to be
NULL.  The second part of this patch changes the implementation to
match the documentation.

Neal


2006-06-12  Neal H. Walfield  <[email protected]>

	* mimedir/mimedir-attribute.c
	(mimedir_attribute_get_parameter_value): Also check if P->VALUES
	is non-NULL before accessing P->VALUES->DATA.
	* mimedir/mimedir-vcomponent.c (mimedir_vcomponent_set_location):
	Set PRIV->LOCATION_ALT to NULL if URI is NULL.

--- mimedir-attribute.c~	2005-11-03 18:04:21.000000000 +0100
+++ mimedir-attribute.c	2006-06-12 13:43:27.000000000 +0200
@@ -1380,7 +1380,7 @@
 	g_return_val_if_fail (parameter != NULL, FALSE);
 
 	p = mimedir_attribute_get_parameter (attribute, parameter);
-	if (p)
+	if (p && p->values)
 		return (gchar *) p->values->data;
 	else
 		return NULL;
--- mimedir-vcomponent.c~	2005-11-03 18:04:21.000000000 +0100
+++ mimedir-vcomponent.c	2006-06-12 13:45:00.000000000 +0200
@@ -2994,7 +2994,7 @@
 	g_free (priv->location);
 	g_free (priv->location_alt);
 	priv->location     = g_strdup (location);
-	priv->location_alt = g_strdup (uri);
+	priv->location_alt = uri ? g_strdup (uri) : NULL;
 }
 
 /**
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.