Skip to content

nob__walk_dir_opt_impl() tries to close zeroed handle for non directory entries #266

Description

@whophi

The nob__walk_dir_opt_impl() function calls nob_dir_entry_close() in the defer, to close the current entry.
It also does this when the entry is not a directory, and therefore the directory handle is NULL.
On Linux, there is a check not to close NULL handles in the nob_dir_entry_close() function, as they are returned on erroneous open.
On Windows, on the other hand, the error handle is INVALID_HANDLE_VALUE, which is not checked anyway.
This results in calls to FindClose with a NULL handle. The result of the close function is not checked, so it continues normally in C.
But FindClose throws an exception, ending the program when used from C++, and more annoyingly triggers the debugger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions