--- xdgmimemagic.c.orig	2004-01-21 09:30:53.000000000 -0500
+++ xdgmimemagic.c	2004-03-03 09:56:42.604700608 -0500
@@ -307,7 +307,7 @@
 _xdg_mime_magic_parse_magic_line (FILE              *magic_file,
 				  XdgMimeMagicMatch *match)
 {
-  XdgMimeMagicMatchlet *matchlet;
+  XdgMimeMagicMatchlet *matchlet, *tmpmatchlet;
   int c;
   int end_of_file;
   int indent = 0;
@@ -496,9 +496,17 @@
 #endif
 	}
 
-      matchlet->next = match->matchlet;
-      match->matchlet = matchlet;
+      if (match->matchlet == NULL) {
+	match->matchlet = matchlet;
+	return XDG_MIME_MAGIC_MAGIC;
+      }
 
+      tmpmatchlet = match->matchlet;
+
+      while (tmpmatchlet->next != NULL)
+        tmpmatchlet = tmpmatchlet->next;
+
+      tmpmatchlet->next = matchlet;
 
       return XDG_MIME_MAGIC_MAGIC;
     }
