]> granicus.if.org Git - nethack/commitdiff
Fix crash with MAIL env variable
authorBobby Durrett <nethack@bobbydurrettdba.com>
Mon, 6 Jun 2016 04:10:26 +0000 (21:10 -0700)
committerBobby Durrett <nethack@bobbydurrettdba.com>
Mon, 6 Jun 2016 04:10:26 +0000 (21:10 -0700)
src/mail.c

index 06ce1b266bdc219396014e5cde8d63810fb963f8..82c7c0925957450acb1f3fe093d19a5d5d34e658 100644 (file)
@@ -90,7 +90,12 @@ free_maildata()
 void
 getmailstatus()
 {
-    if (!mailbox && !(mailbox = nh_getenv("MAIL"))) {
+    char *emailbox;
+    if (emailbox = nh_getenv("MAIL")) {
+        mailbox = (char *) alloc((unsigned) strlen(emailbox));
+        Strcpy(mailbox, emailbox);
+    }
+    if (!mailbox) {
 #ifdef MAILPATH
 #ifdef AMS
         struct passwd ppasswd;