Commit 523de346 authored by Bastien Nocera's avatar Bastien Nocera
Browse files

Fix crasher with incomplete magic element

https://bugs.freedesktop.org/show_bug.cgi?id=28527
parent d3351885
......@@ -70,7 +70,7 @@ uninstall-hook:
all: check
$(MAKE) -C po shared-mime-info.pot
check: freedesktop.org.xml check-translations
check: freedesktop.org.xml update-mime-database check-translations
if test -n $(XMLLINT) ; then \
if test -e $(top_builddir)/freedesktop.org.xml; then \
xmllint --noout --valid $(top_builddir)/freedesktop.org.xml; \
......@@ -78,6 +78,9 @@ check: freedesktop.org.xml check-translations
xmllint --noout --valid $(top_srcdir)/freedesktop.org.xml; \
fi \
fi
if test -d .git/ && test -x $(top_builddir)/update-mime-database && test -d $(top_srcdir)/mime-db-tests ; then \
$(top_builddir)/update-mime-database mime-db-tests/ ; \
fi
if test -d .git/ && test -x ../xdgmime/src/test-mime-data && test -x $(top_builddir)/test-tree-magic ; then \
mkdir -p $(top_builddir)/temp-mime-dir/mime/packages ; \
cp -a $(top_builddir)/freedesktop.org.xml $(top_builddir)/temp-mime-dir/mime/packages/ ; \
......
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-php">
<sub-class-of type="text/plain"/>
<generic-icon name="text-x-script"/>
<magic priority="50"/>
<glob pattern="*.inc"/>
<comment>PHP script</comment>
</mime-type>
<mime-type type="text/html">
<sub-class-of type="text/html"/>
<generic-icon name="text-html"/>
<magic priority="50"/>
<glob pattern="*.tpl"/>
<comment>Smarty template</comment>
</mime-type>
</mime-info>
......@@ -1529,6 +1529,7 @@ static Magic *magic_new(xmlNode *node, Type *type, GError **error)
magic->type = type;
magic->matches = build_matches(node, error);
if (*error)
{
gchar *old = (*error)->message;
......@@ -1537,6 +1538,11 @@ static Magic *magic_new(xmlNode *node, Type *type, GError **error)
(*error)->message = g_strconcat(
_("Error in <match> element: "), old, NULL);
g_free(old);
} else if (magic->matches == NULL) {
magic_free(magic);
magic = NULL;
g_set_error(error, MIME_ERROR, 0,
_("Incomplete <magic> element"));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment