Skip to content
  • rswindell's avatar
    Don't leak FILE streams for calls to js_CreateFileObject(), setting external · c20f74cc
    rswindell authored
    to TRUE meant the FILE* (created with fdopen) would never be closed. So we now
    duplicate the file descriptor and get rid of the external flag, always closing
    Files (FILE streams) upon File object finalize.
    This fixes the resource leak leading to the eventual "Error 24 opening ..." in
    the ircd.js when loaded via jsexec, on Windows. This error happened after
    169 calls to load(true,...), because each background load creates 3 Files
    (for stdin/out/err) and those FILE streams were never closed/freed, and
    169 * 3 = 507, plus a few open files = 512, the maximum number of open file
    streams in the Microsoft CRTL apparently. Thanks to Deuce for recognizing these
    numbers as "magic" and pointing to the likely cause.
    c20f74cc