diff --git a/rogue4/mach_dep.c b/rogue4/mach_dep.c index 7333bc3..30b6747 100644 --- a/rogue4/mach_dep.c +++ b/rogue4/mach_dep.c @@ -120,7 +120,8 @@ setup() #ifdef SIGBUS signal(SIGBUS, auto_save); #endif - signal(SIGSEGV, auto_save); + /* Don't bother saving a game that segfaulted. */ + signal(SIGSEGV, SIG_DFL); #ifdef SIGSYS signal(SIGSYS, auto_save); #endif diff --git a/rogue4/mdport.c b/rogue4/mdport.c index 169e496..4b8f656 100644 --- a/rogue4/mdport.c +++ b/rogue4/mdport.c @@ -53,6 +53,7 @@ char *strdup(const char *s); #include #include +#include #if defined(_WIN32) && !defined(__MINGW32__) #define PATH_MAX MAX_PATH @@ -265,8 +266,10 @@ md_getusername(int uid) struct passwd *pw; pw = getpwuid(getuid()); - - l = pw->pw_name; + if (pw != NULL) + l = pw->pw_name; + else + l = NULL; #endif if ((l == NULL) || (*l == '\0')) @@ -295,8 +298,10 @@ md_gethomedir() char slash = '/'; struct passwd *pw; pw = getpwuid(getuid()); - - h = pw->pw_dir; + if (pw != NULL) + h = pw->pw_dir; + else + h = ""; if (strcmp(h,"/") == 0) h = NULL; @@ -343,7 +348,10 @@ md_getshell() char *def = "/bin/sh"; struct passwd *pw; pw = getpwuid(getuid()); - s = pw->pw_shell; + if (pw != NULL) + s = pw->pw_shell; + else + s = NULL; #endif if ((s == NULL) || (*s == '\0')) if ( (s = getenv("COMSPEC")) == NULL)