Fix(#10687): address null pointer dereference on navigate

This commit is contained in:
Yannick Martin 2026-01-16 18:14:46 +01:00
parent bba6a76f4a
commit 1f7c38c792
No known key found for this signature in database
GPG key ID: AABC9B180F109264
5 changed files with 36 additions and 24 deletions

View file

@ -52,11 +52,13 @@ class Comment : ConfigObject < CommentNameComposer
}
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return nullptr;
if (!GetServiceName().IsEmpty()) {
Host::Ptr host = Host::GetByName(GetHostName());
if (host)
return host->GetServiceByShortName(GetServiceName());
}
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());
return nullptr;
}}}
};

View file

@ -42,11 +42,13 @@ class Dependency : CustomVarObject < DependencyNameComposer
}
}}}
navigate {{{
if (GetChildServiceName().IsEmpty())
return nullptr;
if (!GetChildServiceName().IsEmpty()) {
Host::Ptr host = Host::GetByName(GetChildHostName());
if (host)
return host->GetServiceByShortName(GetChildServiceName());
}
Host::Ptr host = Host::GetByName(GetChildHostName());
return host->GetServiceByShortName(GetChildServiceName());
return nullptr;
}}}
};
@ -69,11 +71,13 @@ class Dependency : CustomVarObject < DependencyNameComposer
}
}}}
navigate {{{
if (GetParentServiceName().IsEmpty())
return nullptr;
if (!GetParentServiceName().IsEmpty()) {
Host::Ptr host = Host::GetByName(GetParentHostName());
if (host)
return host->GetServiceByShortName(GetParentServiceName());
}
Host::Ptr host = Host::GetByName(GetParentHostName());
return host->GetServiceByShortName(GetParentServiceName());
return nullptr;
}}}
};

View file

@ -43,11 +43,13 @@ class Downtime : ConfigObject < DowntimeNameComposer
}
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return nullptr;
if (!GetServiceName().IsEmpty()) {
Host::Ptr host = Host::GetByName(GetHostName());
if (host)
return host->GetServiceByShortName(GetServiceName());
}
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());
return nullptr;
}}}
};

View file

@ -61,11 +61,13 @@ class Notification : CustomVarObject < NotificationNameComposer
}
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return nullptr;
if (!GetServiceName().IsEmpty()) {
Host::Ptr host = Host::GetByName(GetHostName());
if (host)
return host->GetServiceByShortName(GetServiceName());
}
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());
return nullptr;
}}}
};

View file

@ -44,11 +44,13 @@ class ScheduledDowntime : CustomVarObject < ScheduledDowntimeNameComposer
}
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return nullptr;
if (!GetServiceName().IsEmpty()) {
Host::Ptr host = Host::GetByName(GetHostName());
if (host)
return host->GetServiceByShortName(GetServiceName());
}
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());
return nullptr;
}}}
};