Don't call g_path_skip_root() unless the path is absolute.

2005-12-01  Tor Lillqvist  <tml@novell.com>

	* glib/gstdio.c (g_stat): Don't call g_path_skip_root() unless
	the path is absolute.
This commit is contained in:
Tor Lillqvist 2005-12-01 04:32:52 +00:00 committed by Tor Lillqvist
parent cbe09f0312
commit 4d4156db1b

View File

@ -599,7 +599,8 @@ g_stat (const gchar *filename,
len = wcslen (wfilename);
while (len > 0 && G_IS_DIR_SEPARATOR (wfilename[len-1]))
len--;
if (len > g_path_skip_root (filename) - filename)
if (len > 0 &&
(!g_path_is_absolute (filename) || len > g_path_skip_root (filename) - filename))
wfilename[len] = '\0';
retval = _wstat (wfilename, (struct _stat *) buf);
@ -626,7 +627,8 @@ g_stat (const gchar *filename,
len = strlen (cp_filename);
while (len > 0 && G_IS_DIR_SEPARATOR (cp_filename[len-1]))
len--;
if (len > g_path_skip_root (filename) - filename)
if (len > 0 &&
(!g_path_is_absolute (filename) || len > g_path_skip_root (filename) - filename))
cp_filename[len] = '\0';
retval = stat (cp_filename, buf);