From 6ac1cf2ec8bb23a8052a4e0ad3f5abec61f47ebd Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 22 Oct 2009 04:14:04 +0300 Subject: [PATCH] Drop terminating slash in _dbus_get_tmpdir The callers will append strings starting with a slash anyway. --- dbus/dbus-sysdeps-win.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 793900806..da8a8ef84 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2465,8 +2465,21 @@ _dbus_get_tmpdir(void) if (tmpdir == NULL) { + char *last_slash; + if (!GetTempPath (sizeof (buf), buf)) - strcpy (buf, "\\"); + { + _dbus_warn ("GetTempPath failed\n"); + _dbus_abort (); + } + + /* Drop terminating backslash or slash */ + last_slash = _mbsrchr (buf, '\\'); + if (last_slash > buf && last_slash[1] == '\0') + last_slash[0] = '\0'; + last_slash = _mbsrchr (buf, '/'); + if (last_slash > buf && last_slash[1] == '\0') + last_slash[0] = '\0'; tmpdir = buf; } -- 2.47.3