[nautilus-actions] Take care of possibly NULL mimetype



commit f4f0273a93e7226f0c983b2ffca2d06a80de66df
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Aug 22 02:22:26 2010 +0200

    Take care of possibly NULL mimetype
    
    Fix bug reported by aikipooh gmail com 

 ChangeLog                   |    6 +++++
 src/core/na-icontext.c      |   47 +++++++++++++++++++++++++-----------------
 src/core/na-selected-info.c |    4 ++-
 3 files changed, 37 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0529f13..0003d7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-08-22 Pierre Wieser <pwieser trychlos org>
+
+	* src/core/na-icontext.c (is_candidate_for_mimetypes):
+	* src/core/na-selected-info.c (na_selected_info_get_mime_type):
+	Take care of possibly NULL mimetype.
+
 2010-08-21 Pierre Wieser <pwieser trychlos org>
 
 	* src/api/na-dbus.h
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index 852d9d4..3709d76 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -648,31 +648,40 @@ is_candidate_for_mimetypes( const NAIContext *object, guint target, GList *files
 			gchar *ftype, *fgroup, *fsubgroup;
 			gboolean match, positive;
 
-			ftype = na_selected_info_get_mime_type( NA_SELECTED_INFO( it->data ));
-			split_mimetype( ftype, &fgroup, &fsubgroup );
 			match = FALSE;
+			ftype = na_selected_info_get_mime_type( NA_SELECTED_INFO( it->data ));
+
+			if( ftype ){
+				split_mimetype( ftype, &fgroup, &fsubgroup );
+
+				for( im = mimetypes ; im && ok ; im = im->next ){
+					const gchar *imtype = ( const gchar * ) im->data;
+					positive = is_positive_assertion( imtype );
 
-			for( im = mimetypes ; im && ok ; im = im->next ){
-				const gchar *imtype = ( const gchar * ) im->data;
-				positive = is_positive_assertion( imtype );
-
-				if( !positive || !match ){
-					if( is_mimetype_of( positive ? imtype : imtype+1, fgroup, fsubgroup )){
-						g_debug( "%s: condition=%s, positive=%s, ftype=%s, fgroup=%s, fsubgroup=%s, matched",
-								thisfn, imtype, positive ? "True":"False", ftype, fgroup, fsubgroup );
-						if( positive ){
-							match = TRUE;
-						} else {
-							ok = FALSE;
+					if( !positive || !match ){
+						if( is_mimetype_of( positive ? imtype : imtype+1, fgroup, fsubgroup )){
+							g_debug( "%s: condition=%s, positive=%s, ftype=%s, fgroup=%s, fsubgroup=%s, matched",
+									thisfn, imtype, positive ? "True":"False", ftype, fgroup, fsubgroup );
+							if( positive ){
+								match = TRUE;
+							} else {
+								ok = FALSE;
+							}
 						}
 					}
 				}
-			}
 
-			if( !match ){
-				gchar *mimetypes_str = na_core_utils_slist_to_text( mimetypes );
-				g_debug( "%s: no positive match found for Mimetypes=%s", thisfn, mimetypes_str );
-				g_free( mimetypes_str );
+				if( !match ){
+					gchar *mimetypes_str = na_core_utils_slist_to_text( mimetypes );
+					g_debug( "%s: no positive match found for Mimetypes=%s", thisfn, mimetypes_str );
+					g_free( mimetypes_str );
+					ok = FALSE;
+				}
+
+			} else {
+				gchar *uri = na_selected_info_get_uri( NA_SELECTED_INFO( it->data ));
+				g_debug( "%s: null mimetype found for %s", thisfn, uri );
+				g_free( uri );
 				ok = FALSE;
 			}
 
diff --git a/src/core/na-selected-info.c b/src/core/na-selected-info.c
index 3bf2bbf..a5b669e 100644
--- a/src/core/na-selected-info.c
+++ b/src/core/na-selected-info.c
@@ -360,7 +360,9 @@ na_selected_info_get_mime_type( const NASelectedInfo *nsi )
 
 	if( !nsi->private->dispose_has_run ){
 
-		mimetype = g_strdup( nsi->private->mimetype );
+		if( nsi->private->mimetype ){
+			mimetype = g_strdup( nsi->private->mimetype );
+		}
 	}
 
 	return( mimetype );



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