diff options
Diffstat (limited to 'win32/mingw.c')
-rw-r--r-- | win32/mingw.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index bedf14784..4c449514a 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -676,11 +676,14 @@ int mingw_rename(const char *pold, const char *pnew) | |||
676 | 676 | ||
677 | static char *gethomedir(void) | 677 | static char *gethomedir(void) |
678 | { | 678 | { |
679 | static char buf[PATH_MAX]; | 679 | static char *buf = NULL; |
680 | DWORD len = sizeof(buf); | 680 | DWORD len = PATH_MAX; |
681 | HANDLE h; | 681 | HANDLE h; |
682 | char *s; | 682 | char *s; |
683 | 683 | ||
684 | if (!buf) | ||
685 | buf = xmalloc(PATH_MAX); | ||
686 | |||
684 | buf[0] = '\0'; | 687 | buf[0] = '\0'; |
685 | if ( !OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &h) ) | 688 | if ( !OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &h) ) |
686 | return buf; | 689 | return buf; |
@@ -701,11 +704,17 @@ static char *gethomedir(void) | |||
701 | return buf; | 704 | return buf; |
702 | } | 705 | } |
703 | 706 | ||
707 | #define NAME_LEN 100 | ||
704 | static char *get_user_name(void) | 708 | static char *get_user_name(void) |
705 | { | 709 | { |
706 | static char user_name[100] = ""; | 710 | static char *user_name = NULL; |
707 | char *s; | 711 | char *s; |
708 | DWORD len = sizeof(user_name); | 712 | DWORD len = NAME_LEN; |
713 | |||
714 | if ( user_name == NULL ) { | ||
715 | user_name = xmalloc(NAME_LEN); | ||
716 | user_name[0] = '\0'; | ||
717 | } | ||
709 | 718 | ||
710 | if ( user_name[0] != '\0' ) { | 719 | if ( user_name[0] != '\0' ) { |
711 | return user_name; | 720 | return user_name; |
@@ -857,7 +866,12 @@ char *realpath(const char *path, char *resolved_path) | |||
857 | 866 | ||
858 | const char *get_busybox_exec_path(void) | 867 | const char *get_busybox_exec_path(void) |
859 | { | 868 | { |
860 | static char path[PATH_MAX] = ""; | 869 | static char *path = NULL; |
870 | |||
871 | if (!path) { | ||
872 | path = xmalloc(PATH_MAX); | ||
873 | path[0] = '\0'; | ||
874 | } | ||
861 | 875 | ||
862 | if (!*path) | 876 | if (!*path) |
863 | GetModuleFileName(NULL, path, PATH_MAX); | 877 | GetModuleFileName(NULL, path, PATH_MAX); |