gcontenttype: Fix a potential NULL pointer dereference
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 26 Nov 2013 11:12:48 +0000 (11:12 +0000)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 27 Nov 2013 10:01:29 +0000 (10:01 +0000)
commit8b9e8dc53b1efba01d760cde9d2cb01fdee51cf7
treeef8001aa58ef81a4587075c66a61ef0c8aa67b81
parentaa28ced44e0460fb01406aa17996d863ffe3cbf6
gcontenttype: Fix a potential NULL pointer dereference

If the initial part of the header (‘MIME-TreeMagic’) is valid, but the
following line does not start with ‘[’ (i.e. is not a valid section
line), insert_matchlet() will be called with a NULL match pointer, and
will crash with a NULL pointer dereference.

Fix this by bailing out if a valid section line isn’t encountered before
the first insert_matchlet() call (i.e. between the header line and the
first data line).

Note that this has not been tested against a real treemagic file; the
fix is purely theoretical.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
gio/gcontenttype.c