mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-16 12:28:48 +02:00
add OOM handling in mimemagic
This commit is contained in:
parent
5419228f63
commit
9f1c59eef2
@ -103,6 +103,8 @@ _xdg_mime_magic_matchlet_new (void)
|
|||||||
XdgMimeMagicMatchlet *matchlet;
|
XdgMimeMagicMatchlet *matchlet;
|
||||||
|
|
||||||
matchlet = malloc (sizeof (XdgMimeMagicMatchlet));
|
matchlet = malloc (sizeof (XdgMimeMagicMatchlet));
|
||||||
|
if (matchlet == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
matchlet->indent = 0;
|
matchlet->indent = 0;
|
||||||
matchlet->offset = 0;
|
matchlet->offset = 0;
|
||||||
@ -355,6 +357,11 @@ _xdg_mime_magic_parse_magic_line (FILE *magic_file,
|
|||||||
return XDG_MIME_MAGIC_ERROR;
|
return XDG_MIME_MAGIC_ERROR;
|
||||||
|
|
||||||
matchlet = _xdg_mime_magic_matchlet_new ();
|
matchlet = _xdg_mime_magic_matchlet_new ();
|
||||||
|
|
||||||
|
/* OOM */
|
||||||
|
if (matchlet == NULL)
|
||||||
|
return XDG_MIME_MAGIC_ERROR;
|
||||||
|
|
||||||
matchlet->indent = indent;
|
matchlet->indent = indent;
|
||||||
matchlet->offset = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
|
matchlet->offset = _xdg_mime_magic_read_a_number (magic_file, &end_of_file);
|
||||||
if (end_of_file)
|
if (end_of_file)
|
||||||
@ -767,6 +774,11 @@ _xdg_mime_magic_read_magic_file (XdgMimeMagic *mime_magic,
|
|||||||
{
|
{
|
||||||
case XDG_MIME_MAGIC_SECTION:
|
case XDG_MIME_MAGIC_SECTION:
|
||||||
match = _xdg_mime_magic_match_new ();
|
match = _xdg_mime_magic_match_new ();
|
||||||
|
|
||||||
|
/* OOM */
|
||||||
|
if (match == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
state = _xdg_mime_magic_parse_header (magic_file, match);
|
state = _xdg_mime_magic_parse_header (magic_file, match);
|
||||||
if (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_ERROR)
|
if (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_ERROR)
|
||||||
_xdg_mime_magic_match_free (match);
|
_xdg_mime_magic_match_free (match);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user