@@ -78,35 +78,36 @@ dylib_t dylib_load(const char *path)
7878 int prevmode = SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX );
7979#endif
8080#ifdef __WINRT__
81+ dylib_t lib ;
8182 /* On UWP, you can only load DLLs inside your install directory, using a special function that takes a relative path */
83+ char relative_path_abbrev [PATH_MAX_LENGTH ];
84+ char * relative_path = relative_path_abbrev ;
85+ wchar_t * path_wide = NULL ;
86+
87+ relative_path_abbrev [0 ] = '\0' ;
8288
8389 if (!path_is_absolute (path ))
8490 RARCH_WARN ("Relative path in dylib_load! This is likely an attempt to load a system library that will fail\n" );
8591
86- char * relative_path_abbrev = (char * )malloc (PATH_MAX_LENGTH * sizeof (char ));
87- fill_pathname_abbreviate_special (relative_path_abbrev , path , PATH_MAX_LENGTH * sizeof (char ));
92+ fill_pathname_abbreviate_special (relative_path_abbrev , path , sizeof (relative_path_abbrev ));
8893
89- char * relative_path = relative_path_abbrev ;
90- if (relative_path [0 ] != ':' || !PATH_CHAR_IS_SLASH (relative_path [1 ]))
91- {
92- /* Path to dylib_load is not inside app install directory.
93- * Loading will probably fail. */
94- }
94+ /* Path to dylib_load is not inside app install directory.
95+ * Loading will probably fail. */
96+ if (relative_path [0 ] != ':' || !PATH_CHAR_IS_SLASH (relative_path [1 ])) { }
9597 else
9698 relative_path += 2 ;
9799
98-
99- wchar_t * pathW = utf8_to_utf16_string_alloc (relative_path );
100- dylib_t lib = LoadPackagedLibrary (pathW , 0 );
101- free (pathW );
100+ path_wide = utf8_to_utf16_string_alloc (relative_path );
101+ lib = LoadPackagedLibrary (path_wide , 0 );
102+ free (path_wide );
102103
103104 free (relative_path_abbrev );
104105#elif defined(LEGACY_WIN32 )
105- dylib_t lib = LoadLibrary (path );
106+ dylib_t lib = LoadLibrary (path );
106107#else
107- wchar_t * pathW = utf8_to_utf16_string_alloc (path );
108- dylib_t lib = LoadLibraryW (pathW );
109- free (pathW );
108+ wchar_t * path_wide = utf8_to_utf16_string_alloc (path );
109+ dylib_t lib = LoadLibraryW (path_wide );
110+ free (path_wide );
110111#endif
111112
112113#ifndef __WINRT__
0 commit comments