Skip to content

Comments

fix use-after-free#509

Merged
BrentDaMage merged 2 commits intoReMinecraftPE:masterfrom
Un1q32:uaf
Feb 23, 2026
Merged

fix use-after-free#509
BrentDaMage merged 2 commits intoReMinecraftPE:masterfrom
Un1q32:uaf

Conversation

@Un1q32
Copy link
Contributor

@Un1q32 Un1q32 commented Feb 22, 2026

According to clang this causes a UAF because the std::string is destroyed, fixed by declaring the temporary std::string in a different scope.

Copy link
Member

@BrentDaMage BrentDaMage left a comment

Choose a reason for hiding this comment

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

static std::string getStoragePath()
{
    // Doing this as a c-string because worst-case, an SDK
    // will return a nullptr instead of an empty string
    std::string path;
    {
        const char* tmp;
#ifdef _WIN32
        tmp = getenv("APPDATA");
        if (tmp)
            path = tmp;
#else
        tmp = getenv("XDG_DATA_HOME");
        if (tmp)
            path = tmp;
        else
        {
            tmp = getenv("HOME");
            if (tmp)
                path = std::string(tmp) + "/.local/share";
            else
                LOG_E("HOME not set");
        }
#endif
    }

    if (!path.empty())
        path += "/";
    path += ".reminecraftpe";

    return path;
}

@Un1q32
Copy link
Contributor Author

Un1q32 commented Feb 23, 2026

done

@BrentDaMage BrentDaMage merged commit 0e6fce4 into ReMinecraftPE:master Feb 23, 2026
13 checks passed
@Un1q32 Un1q32 deleted the uaf branch February 23, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants