summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/dive.c b/core/dive.c
index c85b869a3..07d47de6f 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -3623,11 +3623,12 @@ timestamp_t get_times()
void set_userid(char *rUserId)
{
+ char *userid = strdup(rUserId);
+ if (strlen(userid) > 30)
+ userid[30] = '\0';
if (prefs.userid)
- free(prefs.userid);
- prefs.userid = strdup(rUserId);
- if (strlen(prefs.userid) > 30)
- prefs.userid[30]='\0';
+ free((void *)prefs.userid);
+ prefs.userid = userid;
}
/* this sets a usually unused copy of the preferences with the units