Skip to content

Conversation

maxolasersquad
Copy link
Contributor

Describe your PR, what does it fix/add?

Resolves a potential null pointer crash and two Time-of-Check to Time-of-Use conditions.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

While Hyprland does some sanity checking when it starts, a future refactor could potentially allow XDG_RUNTIME_DIR to not be set in the CCompositor constructor. If that happened a null pointer exception would be thrown. I added a check to make sure this cannot happen.

A very minor change is that m_hyprTempDataRoot is now constructed with std::filesystem so that the platform will build the directory separators itself.

Two possible TOCTOU conditions existed when created hyprTempDataRoot directory and when creating the instancePath directories. These are now patched up with ask-for-forgiveness.

Is it ready for merging, or does it need work?

I compiled these changes on an Arch system and Hyprland still runs fine.

@github-actions github-actions bot added the core label Aug 8, 2025
@maxolasersquad maxolasersquad force-pushed the compositor-improvements branch from beb0dfd to b978263 Compare August 13, 2025 00:28
@maxolasersquad maxolasersquad force-pushed the compositor-improvements branch from b978263 to 1b0e1f1 Compare August 23, 2025 02:07
@maxolasersquad maxolasersquad force-pushed the compositor-improvements branch from 1b0e1f1 to 0f2d34a Compare August 23, 2025 02:08
else if (!std::filesystem::is_directory(m_hyprTempDataRoot)) {
std::println("Bailing out, {} is not a directory", m_hyprTempDataRoot);
std::error_code ec;
std::filesystem::create_directories(m_hyprTempDataRoot, ec);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we can't use STL here because it doesn't offer permissions for the directory at creation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants