[libdmapsharing] Check if object attributes are NULL in add_entry_to_mlcl Signed-off-by: W. Michael Petullo <mike fly



commit e6b09029e855bc169b014ac56e701504be25661a
Author: W. Michael Petullo <mike flyn org>
Date:   Sat Oct 16 12:20:11 2010 -0500

    Check if object attributes are NULL in add_entry_to_mlcl
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/daap-share.c |   35 +++++++++++++++++++++++++----------
 libdmapsharing/dpap-share.c |   35 +++++++++++++++++++++++++----------
 2 files changed, 50 insertions(+), 20 deletions(-)
---
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index 7e4d53b..7dcd2d5 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -558,8 +558,11 @@ add_entry_to_mlcl (gpointer id,
 	if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
 		gchar *title;
 		g_object_get (record, "title", &title, NULL);
-		dmap_structure_add (mlit, DMAP_CC_MINM, title);
-		g_free (title);
+		if (title) {
+			dmap_structure_add (mlit, DMAP_CC_MINM, title);
+			g_free (title);
+		} else
+			g_warning ("Title requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID))
 		dmap_structure_add (mlit, DMAP_CC_MPER, GPOINTER_TO_UINT (id));
@@ -574,16 +577,22 @@ add_entry_to_mlcl (gpointer id,
 	if (_dmap_share_client_requested (mb->bits, SONG_ALBUM)) {
 		gchar *album;
 		g_object_get (record, "songalbum", &album, NULL);
-		dmap_structure_add (mlit, DMAP_CC_ASAL, album);
-		g_free (album);
+		if (album) {
+			dmap_structure_add (mlit, DMAP_CC_ASAL, album);
+			g_free (album);
+		} else
+			g_warning ("Album requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, SONG_GROUPING))
 		dmap_structure_add (mlit, DMAP_CC_AGRP, "");
 	if (_dmap_share_client_requested (mb->bits, SONG_ARTIST)) {
 		gchar *artist;
 		g_object_get (record, "songartist", &artist, NULL);
-		dmap_structure_add (mlit, DMAP_CC_ASAR, artist);
-		g_free (artist);
+		if (artist) {
+			dmap_structure_add (mlit, DMAP_CC_ASAR, artist);
+			g_free (artist);
+		} else
+			g_warning ("Artist requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, SONG_BITRATE)) {
 		gint32 bitrate;
@@ -626,14 +635,20 @@ add_entry_to_mlcl (gpointer id,
 			format = g_strdup (transcode_format);
 		else
 			g_object_get (record, "format", &format, NULL);
-		dmap_structure_add (mlit, DMAP_CC_ASFM, format);
-		g_free (format);
+		if (format) {
+			dmap_structure_add (mlit, DMAP_CC_ASFM, format);
+			g_free (format);
+		} else
+			g_warning ("Format requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, SONG_GENRE)) {
 		gchar *genre;
 		g_object_get (record, "songgenre", &genre, NULL);
-		dmap_structure_add (mlit, DMAP_CC_ASGN, genre);
-		g_free (genre);
+		if (genre) {
+			dmap_structure_add (mlit, DMAP_CC_ASGN, genre);
+			g_free (genre);
+		} else
+			g_warning ("Genre requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, SONG_DESCRIPTION))
 		dmap_structure_add (mlit, DMAP_CC_ASDT, ""); /* FIXME: e.g., wav audio file */
diff --git a/libdmapsharing/dpap-share.c b/libdmapsharing/dpap-share.c
index 5105f2d..dfe53ad 100644
--- a/libdmapsharing/dpap-share.c
+++ b/libdmapsharing/dpap-share.c
@@ -363,8 +363,11 @@ add_entry_to_mlcl (gpointer id,
 	if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
 		gchar *filename;
 		g_object_get (record, "filename", &filename, NULL);
-		dmap_structure_add (mlit, DMAP_CC_MINM, filename);
-		g_free (filename);
+		if (filename) {
+			dmap_structure_add (mlit, DMAP_CC_MINM, filename);
+			g_free (filename);
+		} else
+			g_warning ("Filename requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID))
 		dmap_structure_add (mlit, DMAP_CC_MPER, GPOINTER_TO_UINT (id));
@@ -373,8 +376,11 @@ add_entry_to_mlcl (gpointer id,
 		 * and this does seem to be the case when testing. */
 		gchar *aspect_ratio;
 		g_object_get (record, "aspect-ratio", &aspect_ratio, NULL);
-		dmap_structure_add (mlit, DMAP_CC_PASP, aspect_ratio);
-		g_free (aspect_ratio);
+		if (aspect_ratio) {
+			dmap_structure_add (mlit, DMAP_CC_PASP, aspect_ratio);
+			g_free (aspect_ratio);
+		} else
+			g_warning ("Aspect ratio requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, PHOTO_CREATIONDATE)) {
 		gint creation_date;
@@ -384,14 +390,20 @@ add_entry_to_mlcl (gpointer id,
 	if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILENAME)) {
 		gchar *filename;
 		g_object_get (record, "filename", &filename, NULL);
-		dmap_structure_add (mlit, DMAP_CC_PIMF, filename);
-		g_free (filename);
+		if (filename) {
+			dmap_structure_add (mlit, DMAP_CC_PIMF, filename);
+			g_free (filename);
+		} else
+			g_warning ("Filename requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFORMAT)) {
 		gchar *format;
 		g_object_get (record, "format", &format, NULL);
-		dmap_structure_add (mlit, DMAP_CC_PFMT, format);
-		g_free (format);
+		if (format) {
+			dmap_structure_add (mlit, DMAP_CC_PFMT, format);
+			g_free (format);
+		} else
+			g_warning ("Format requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILESIZE)) {
 		gint filesize;
@@ -421,8 +433,11 @@ add_entry_to_mlcl (gpointer id,
 	if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGECOMMENTS)) {
 		gchar *comments;
 		g_object_get (record, "comments", &comments, NULL);
-		dmap_structure_add (mlit, DMAP_CC_PCMT, comments);
-		g_free (comments);
+		if (comments) {
+			dmap_structure_add (mlit, DMAP_CC_PCMT, comments);
+			g_free (comments);
+		} else
+			g_warning ("Comments requested but not available");
 	}
 	if (_dmap_share_client_requested (mb->bits, PHOTO_FILEDATA)) {
 		size_t size = 0;



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