Handle setModule(NULL) more safely.

If module_name is null, we can't do much of anything - we don't have a
protocol ID, so we don't have a protocol.

Change-Id: I42c2fa4b47e39d7ac122c60be91b5d408bf30a1d
Reviewed-on: https://code.wireshark.org/review/9569
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-07-08 16:19:19 -07:00
parent e312d41883
commit 131e0ab7ea
1 changed files with 3 additions and 6 deletions

View File

@ -184,12 +184,9 @@ void ProtocolPreferencesMenu::setModule(const char *module_name)
module_name_.clear();
module_ = NULL;
if (module_name) {
proto_id = proto_get_id_by_filter_name(module_name);
protocol = find_protocol_by_id(proto_id);
}
if (proto_id < 0 || !protocol) {
if (!module_name ||
(proto_id = proto_get_id_by_filter_name(module_name)) < 0 ||
!(protocol = find_protocol_by_id(proto_id))) {
action = addAction(tr("No protocol preferences available"));
action->setDisabled(true);
return;