Fix incorrect memory access in nickname handling

There was one code path where we didn't strdup the nickname - and this got
triggered when parsing XML files with divecomputerid entries for dive
computers that were already in the config. The nickname is then replaced
with the nickname from the parser - and that memory is later reused...

We should cleanup that nickname, anyway, and that also takes care of
making sure we have our own copy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-12-27 21:38:23 -08:00
parent fd03fcd66d
commit f6fb882337

View file

@ -2188,7 +2188,7 @@ void remember_dc(const char *model, uint32_t deviceid, const char *nickname, gbo
struct dcnicknamelist *nn_entry = get_dc_nicknameentry(model, deviceid);
if (!nn_entry->model || !*nn_entry->model)
nn_entry->model = model;
nn_entry->nickname = nickname;
nn_entry->nickname = cleanedup_nickname(nickname, 80);
replace_nickname_nicknamestring(model, deviceid, nickname);
}
#if defined(NICKNAME_DEBUG)