Decode As: Don't crash on a (none) configuration entry

Our current code doesn't allow truly disabling decoding via
Decode As for something with a default handle through the GUI,
but if the decode_as_entries configuration file has such an
entry (which it could if edited manually), don't crash from
attempting to lookup information about the NULL protocol handle
to set a nonexistent preference.
This commit is contained in:
John Thacker 2023-05-21 07:49:43 -04:00
parent 5bd4bb8b27
commit de347765f5
1 changed files with 15 additions and 14 deletions

View File

@ -248,23 +248,24 @@ read_set_decode_as_entries(gchar *key, const gchar *value,
}
/* Now apply the value data back to dissector table preference */
proto_name = proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle));
module = prefs_find_module(proto_name);
pref_value = prefs_find_preference(module, values[0]);
if (pref_value != NULL) {
gboolean replace = FALSE;
if (g_hash_table_lookup(processed_entries, proto_name) == NULL) {
/* First decode as entry for this protocol, ranges may be replaced */
replace = TRUE;
if (handle != NULL) {
proto_name = proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle));
module = prefs_find_module(proto_name);
pref_value = prefs_find_preference(module, values[0]);
if (pref_value != NULL) {
gboolean replace = FALSE;
if (g_hash_table_lookup(processed_entries, proto_name) == NULL) {
/* First decode as entry for this protocol, ranges may be replaced */
replace = TRUE;
/* Remember we've processed this protocol */
g_hash_table_insert(processed_entries, (gpointer)proto_name, (gpointer)proto_name);
/* Remember we've processed this protocol */
g_hash_table_insert(processed_entries, (gpointer)proto_name, (gpointer)proto_name);
}
prefs_add_decode_as_value(pref_value, (guint)long_value, replace);
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
}
prefs_add_decode_as_value(pref_value, (guint)long_value, replace);
module->prefs_changed_flags |= prefs_get_effect_flags(pref_value);
}
}
}
if (is_valid) {