Simply ignore magic types that we don't know, but do not leak memory.

The new libmagic e.g. supports the types 'search/xxx' and 'regex'.

--- php.ori/ext/mime_magic/mime_magic.c	2009-03-17 08:54:00.000000000 +0100
+++ php.new/ext/mime_magic/mime_magic.c	2009-03-17 09:41:58.000000000 +0100
@@ -450,16 +450,6 @@
     /* allocate magic structure entry */
     m = (struct magic *) calloc(1, sizeof(struct magic));
 
-    /* append to linked list */
-    m->next = NULL;
-    if (!conf->magic || !conf->last) {
-		conf->magic = conf->last = m;
-    }
-    else {
-		conf->last->next = m;
-		conf->last = m;
-    }
-
     /* set values in magic structure */
     m->flag = 0;
     m->cont_level = 0;
@@ -601,9 +591,13 @@
 		l += NLEDATE;
     }
     else {
+		/* omit the warning. There *are* types we don't know. */
+#if 0
 		php_error(E_WARNING,
 					 MODNAME ": type %s invalid", l);
-		return -1;
+#endif
+		goto cleanup;
+		
     }
     /* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
     if (*l == '&') {
@@ -643,7 +637,7 @@
     EATAB;
 
     if (getvalue(m, &l))
-		return -1;
+		goto cleanup;
     /*
      * now get last part - the description
      */
@@ -661,7 +655,23 @@
     else
 		m->nospflag = 0;
     strlcpy(m->desc, l, sizeof(m->desc));
+
+	/* append to linked list */
+	m->next = NULL;
+	if (!conf->magic || !conf->last) {
+		conf->magic = conf->last = m;
+	}
+	else {
+		conf->last->next = m;
+		conf->last = m;
+	}
     return 0;
+
+  cleanup:
+	/* drop entry */
+	free(m);
+	/* return value is eventually ignored anyway */
+	return -1;
 }
 
 /*

