Dear All,

Subsurface would crash on my Ubuntu 14.04 using my own build of the current
head of master (72806e42bc23ab7c7f2a639a1efee017388b53bc, aug 18). The
culprit was that I had no LOGNAME variable in my environment. Running
subsurface as "LOGNAME='whatever' ./subsurface" was a quick workaround.

Please find attached a trivial patch that checks if there are NULL pointers
returned by getenv, and if so defaults to "~" and/or "default" for the HOME
and LOGNAME variables.

kind regards,
Sander Kleijwegt

diff --git a/linux.c b/linux.c
index 3ffd997..ff761bc 100644
--- a/linux.c
+++ b/linux.c
@@ -55,7 +55,11 @@ const char *system_default_filename(void)
 	int len;
 
 	home = getenv("HOME");
+        if(!home)
+                home = "~";
 	user = getenv("LOGNAME");
+        if(!user)
+               user = "default";
 	len = strlen(home) + strlen(user) + 17;
 	buffer = malloc(len);
 	snprintf(buffer, len, "%s/subsurface/%s.xml", home, user);

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to