Merge pull request #10698 from ymartin-ovh/pr-10687

Fix nullptr dereference on `{child_,parent_}service` navigation
This commit is contained in:
Yonas Habteab 2026-01-30 16:49:19 +01:00 committed by GitHub
commit 36b41dbe11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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

@ -44,11 +44,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;
}}}
};
@ -71,11 +73,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

@ -69,11 +69,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;
}}}
};