Fix potential memory leak

If we hit the depth limit, filename leaks. Move the depth check up before we
allocate filename.
Introduced in 226622349a.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
Peter Hutterer 2015-05-18 07:55:17 +10:00
parent d3415d1f05
commit 013ccece12

View file

@ -496,10 +496,10 @@ parseline(
token = nexttoken(fp, tokenbuf, &lastch);
if (token != KEY && token != STRING)
goto error;
if ((filename = TransFileName(im, tokenbuf)) == NULL)
goto error;
if (++depth > 100)
goto error;
if ((filename = TransFileName(im, tokenbuf)) == NULL)
goto error;
infp = _XFopenFile(filename, "r");
Xfree(filename);
if (infp == NULL)