Skip to content

assert for filepath const char* parameters for nullptr #332

@ZXShady

Description

@ZXShady

this function in CSFML Font.cpp

sfFont* sfFont_createFromFile(const char* filename)
{
    sf::Font font;
    if (!font.openFromFile(filename)) // implicitly construct std::filesystem::path from filename
        return nullptr;

    return new sfFont{std::move(font), {}, {}};
}

I cannot find from cppreference whether it is UB or not to pass nullptr to std::filesystem::path so I looked into libstdc++ and when you pass a const char* into std::filesystem::path it will construct a path::string_type (alias to std::string) which is UB to pass nullptr for.

https://github.com/gcc-mirror/gcc/blob/5d9486c29938d79beb798dce1a5509da54fe8c9f/libstdc%2B%2B-v3/include/experimental/bits/fs_path.h#L465C3-L468C1

functions

Texture.cpp
1
2

SoundBuffer.cpp
1

Image.cpp
1

Font.cpp
1

Music.cpp
1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions