changeset 265:3f14da3c3b9a

Fix a segfault on fullscreen file deletion reported by Frdric Mantegazza.
author zas_
date Mon, 07 Apr 2008 19:06:17 +0000
parents 1015282898fe
children 65187a2309d3
files src/image-overlay.c
diffstat 1 files changed, 19 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/image-overlay.c	Mon Apr 07 18:52:54 2008 +0000
+++ b/src/image-overlay.c	Mon Apr 07 19:06:17 2008 +0000
@@ -258,32 +258,33 @@
   	g_free(name_escaped);
 	g_hash_table_destroy(vars);
 
+	text2 = text;
 	{
 	FileData *fd = image_get_fd(imd);
-	gint active_marks = 0;
-	gint mark;
 
-	for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) 
+	if (fd) /* fd may be null after file deletion */
 		{
-		active_marks += fd->marks[mark];
-		}
+		gint active_marks = 0;
+		gint mark;
 
-	if (active_marks > 0)
-		{
-		GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
-	        
 		for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) 
 			{
-			g_string_append_printf(buf, fd->marks[mark] ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
-    			}
+			active_marks += fd->marks[mark];
+			}
 
-    		text2 = g_strdup_printf("%s\n%s", text, buf->str);
-		g_string_free(buf, TRUE);
-		g_free(text);
-		}
-	else
-		{
-		text2 = text;
+		if (active_marks > 0)
+			{
+			GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
+	        
+			for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++) 
+				{
+				g_string_append_printf(buf, fd->marks[mark] ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
+    				}
+
+    			text2 = g_strdup_printf("%s\n%s", text, buf->str);
+			g_string_free(buf, TRUE);
+			g_free(text);
+			}
 		}
 	}