When rules are configured which reference ipsets and no ipsets are declared
at all, fw4 crashed with a null reference exception while validating the
rule.
Solve the issue by using the optional chaining operator on the potentially
null filter result.
Ref: https://forum.openwrt.org/t/x/144176
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
let ipset;
if (rule.ipset) {
- ipset = filter(this.state.ipsets, s => (s.name == rule.ipset.name))[0];
+ ipset = filter(this.state.ipsets, s => (s.name == rule.ipset.name))?.[0];
if (!ipset) {
this.warn_section(data, `references unknown set '${rule.ipset.name}'`);
let ipset;
if (redir.ipset) {
- ipset = filter(this.state.ipsets, s => (s.name == redir.ipset.name))[0];
+ ipset = filter(this.state.ipsets, s => (s.name == redir.ipset.name))?.[0];
if (!ipset) {
this.warn_section(data, `references unknown set '${redir.ipset.name}'`);