Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Possible file handle leak in gamedef.c #11

Open
qdii opened this issue Sep 21, 2013 · 0 comments
Open

Possible file handle leak in gamedef.c #11

qdii opened this issue Sep 21, 2013 · 0 comments

Comments

@qdii
Copy link

qdii commented Sep 21, 2013

void copydefaultcons(void)
{
    long i, fs, fpi;
    FILE *fpo;

    for(i=0;i<3;i++)
    {
        fpi = TCkopen4load(defaultcons[i],1);
        fpo = fopen( defaultcons[i],"wb");

        if(fpi == 0)
        {
        // CTW - MODIFICATION
        // if(fpo == -1) fclose(fpo);
            if(fpo == NULL) fclose(fpo);
        // CTW END - MODIFICATION
            continue;
        }
    //...
}

The line:

if (fpo == NULL) fclose(fpo); 

does not close fpo properly, causing a file handle leak when fpi == 0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant