Skip to content

Commit

Permalink
Fix possible null pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Sep 14, 2024
1 parent 070c270 commit 63e3992
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Source/GameClasses/ClientPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct ClientPanel {

[[nodiscard]] decltype(auto) uiPanel() const noexcept
{
return hookContext.template make<PanoramaUiPanel>(panel->uiPanel);
return hookContext.template make<PanoramaUiPanel>(uiPanelPointer());
}

template <template <typename> typename T>
Expand All @@ -25,6 +25,13 @@ struct ClientPanel {
}

private:
[[nodiscard]] cs2::CUIPanel* uiPanelPointer() const noexcept
{
if (panel)
return panel->uiPanel;
return nullptr;
}

HookContext& hookContext;
cs2::CPanel2D* panel;
};
9 changes: 8 additions & 1 deletion Source/GameClasses/PanoramaUiPanelContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct PanoramaUiPanelContext {

[[nodiscard]] decltype(auto) clientPanel() const noexcept
{
return hookContext.template make<ClientPanel>(panel->clientPanel);
return hookContext.template make<ClientPanel>(clientPanelPointer());
}

template <template <typename> typename T>
Expand Down Expand Up @@ -124,6 +124,13 @@ struct PanoramaUiPanelContext {
}

private:
[[nodiscard]] cs2::CPanel2D* clientPanelPointer() const noexcept
{
if (panel)
return panel->clientPanel;
return nullptr;
}

[[nodiscard]] cs2::CPanelStyle* getStyle() const noexcept
{
return impl().panelStyle.of(panel).get();
Expand Down

0 comments on commit 63e3992

Please sign in to comment.