From 9215030085873ff4317d2f1c47c3455194cd42d7 Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 22 Nov 2019 15:45:28 +0100 Subject: Use _fullpath() instead of GetFullPathNameA(). Win32 docs says that GetFullPathNameA() is not recommended with multi-threaded applications, since it uses a global variable. As appstream-glib is a library and can potentially be used in any software, included in multi-thread cases, let's use _fullpath() instead. --- libappstream-glib/as-self-test.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 6ed3116..47ad937 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -93,15 +93,12 @@ as_test_get_filename (const gchar *filename) } #ifdef _WIN32 { - DWORD retval; - TCHAR full_path[PATH_MAX]; - - retval = GetFullPathNameA (path, PATH_MAX, full_path, NULL); - - if (retval > 0) - return g_strdup (full_path); - else + char full_path[PATH_MAX]; + if (_fullpath (full_path, path, PATH_MAX) == NULL) + return NULL; + if (!g_file_test (full_path, G_FILE_TEST_EXISTS)) return NULL; + return g_strdup (full_path); } #else return realpath (path, NULL); -- cgit v1.2.1