Skip to content

Suggestion: Ensure file streams are explicitly closed before quitting on invalid points (Infinity) #221

@kidw0124

Description

@kidw0124

Hello! While reviewing the code related to points parsing (around lines 3173-3174), I noticed a specific edge case handling.

// testlib.h
if (__testlib_points == std::numeric_limits<float>::infinity())
    quit(_fail, "Expected points, but infinity found");

When __testlib_points is evaluated as infinity, the program calls quit(_fail, ...) immediately.

It appears that at this stage, the standard file resultFile = testlib_fopen_(resultName.c_str(), "w"); in 3159 line might still be open. While the operating system typically cleans up file descriptors upon process termination, relying on implicit cleanup can sometimes lead to unflushed buffers or inconsistent states, especially in specific environments.

Suggestion: Would it be safer to ensure that open file streams are explicitly closed (or buffers flushed) before triggering the quit function in this error path? This would adhere more strictly to RAII principles and ensure a clean exit.

Thank you for maintaining this amazing library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions