Qt: Check for NULL pointer in profile->reference

Check for NULL pointer before using profile->reference in strcmp()
because this will give a crash. Doing a copy profile from a new profile
will set the reference to NULL in get_profile_parent().

Use an unambiguously profile reference value NULL as profile->reference
when creating a new profile to align with when copy from a new profile.

Change-Id: Ib27a1a309776e9c2ec44677f2d22f9a5635dd38a
Reviewed-on: https://code.wireshark.org/review/34137
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Stig Bjørlykke 2019-07-30 12:31:38 +02:00 committed by Roland Knall
parent 5d0a2ccbb7
commit 927afac570
1 changed files with 2 additions and 2 deletions

View File

@ -502,7 +502,7 @@ QModelIndex ProfileModel::addNewProfile(QString name)
cnt++;
}
add_to_profile_list(newName.toUtf8().constData(), "", PROF_STAT_NEW, FALSE, FALSE);
add_to_profile_list(newName.toUtf8().constData(), Q_NULLPTR, PROF_STAT_NEW, FALSE, FALSE);
loadProfiles();
return index(findByName(newName), COL_NAME);
@ -629,7 +629,7 @@ bool ProfileModel::setData(const QModelIndex &idx, const QVariant &value, int ro
g_free(prof->name);
prof->name = qstring_strdup(value.toString());
if (strcmp(prof->name, prof->reference) == 0) {
if (prof->reference && strcmp(prof->name, prof->reference) == 0) {
prof->status = PROF_STAT_EXISTS;
} else if (prof->status == PROF_STAT_EXISTS) {
prof->status = PROF_STAT_CHANGED;