diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-10-11 17:35:31 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-10-11 17:35:31 -0400 |
commit | 9882bf5ff8762ebe4741b6380c3ed1088027e5cc (patch) | |
tree | 687eaa67114ed269681b740f1a820af3fedfe93e | |
parent | 43765d2897cfa4ca0bd53bdab4973929f64adedf (diff) | |
download | subsurface-9882bf5ff8762ebe4741b6380c3ed1088027e5cc.tar.gz |
Just use strdup
In commit 272f85bb2444 ("Fix silly crash") I indeed fixed the crash, but I
also broke the code. Now a broken userid might end upsaved in the data
file. Oops.
This should be correct now.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | dive.c | 8 |
1 files changed, 1 insertions, 7 deletions
@@ -2505,7 +2505,6 @@ timestamp_t get_times() return dive->when; } -#define MAX_USERID_SIZE 32 void set_save_userid_local(short value) { prefs.save_userid_local = value; @@ -2513,13 +2512,8 @@ void set_save_userid_local(short value) void set_userid(char *rUserId) { - prefs.userid = (char *)malloc(MAX_USERID_SIZE + 1); - if (prefs.userid && rUserId) { - strncpy(prefs.userid, rUserId, MAX_USERID_SIZE); - prefs.userid[MAX_USERID_SIZE] = 0; - } + prefs.userid = strdup(rUserId); } -#undef MAX_USERID_SIZE int average_depth(struct diveplan *dive) { |