Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak under certain conditions #55

Open
ZOulhadj opened this issue Dec 21, 2022 · 0 comments
Open

Memory leak under certain conditions #55

ZOulhadj opened this issue Dec 21, 2022 · 0 comments
Labels
bug Feature that must be fixed

Comments

@ZOulhadj
Copy link
Owner

At the time of writing, there is a potential memory leak in certain functions. For example, when creating a window the structure is allocated on the heap and if the actual window creation function call fails then this simply returns without freeing the previously allocated memory. Below is an example of this:

    window_t* window = new window_t();

    glfwSetErrorCallback(glfw_error_callback);

    if (!glfwInit()) {
        logger::err("Failed to initialize GLFW");

        return nullptr;
    }


    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
    glfwWindowHint(GLFW_RESIZABLE, true);

    window->handle = glfwCreateWindow(width, height, name, nullptr, nullptr);
    window->name   = name;
    window->width  = width;
    window->height = height;

    if (!window->handle) {
        logger::err("Failed to create GLFW window");

        return nullptr;
    }

@ZOulhadj ZOulhadj added the bug Feature that must be fixed label Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Feature that must be fixed
Projects
None yet
Development

No branches or pull requests

1 participant