Free any previous userid before setting new

When we load multiple files, we call set_userid multiple times. Then we
need to free the old user id before we set a new.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2014-12-18 10:47:00 -08:00 committed by Dirk Hohndel
parent 65a988a232
commit 8d54c9640d

2
dive.c
View file

@ -2749,6 +2749,8 @@ void set_save_userid_local(short value)
void set_userid(char *rUserId)
{
if (prefs.userid)
free(prefs.userid);
prefs.userid = strdup(rUserId);
if (strlen(prefs.userid) > 30)
prefs.userid[30]='\0';