Skip to content

glfw: Leftover errdefer in glfw.init #826

@Luexa

Description

@Luexa

pub inline fn init(hints: InitHints) bool {
internal_debug.toggleInitialized();
internal_debug.assertInitialized();
errdefer {
internal_debug.assertInitialized();
internal_debug.toggleInitialized();
}

The errdefer here will not trigger as glfw.init() returns a bool, not an error union. This means that the assert will be incorrectly triggered if glfw.init() is invoked after a previous invocation of glfw.init() returned false. Some other mechanism is required to unset the debug value.

Also, glfw.terminate() shouldn't need to assert that GLFW is initialized, as glfwTerminate() has well defined behavior of doing nothing when glfwInit() has not returned successfully. Of course, the debug value should still be unset on glfw.terminate().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions