#46 libindi-0.9.7/indidriver.c:1084]: (error) Resource leak: fpin

1.2.X
accepted
nobody
None
1
2016-02-11
2014-02-20
dcb
No

Source code is

FILE *fpin = fopen(configFileName, "r");
  if(fpin != NULL)
  {
    FILE *fpout = fopen(configDefaultFileName, "w");
    if(fpout != NULL)
    {
      int ch = 0;
      while((ch = getc(fpin)) != EOF)
        putc(ch, fpout);

      fclose(fpin);
      fclose(fpout);
   }
}

Suggest new code

FILE *fpin = fopen(configFileName, "r");
  if(fpin != NULL)
  {
    FILE *fpout = fopen(configDefaultFileName, "w");
    if(fpout != NULL)
    {
      int ch = 0;
      while((ch = getc(fpin)) != EOF)
        putc(ch, fpout);

      fclose(fpout);
   }
   fclose(fpin);
}

Discussion

  • Jasem Mutlaq

    Jasem Mutlaq - 2014-02-20

    Thanks for the report! Fix applied.

     
  • Jasem Mutlaq

    Jasem Mutlaq - 2014-02-20
    • status: open --> accepted
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks