Uploaded image for project: 'rosapps SVN Repository'
  1. rosapps SVN Repository
  2. ROSAPPS-192

resource leak in file xml.c

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • Utilities
    • None
    • Operating System: ReactOS
      Platform: x86 Hardware

    Description

      Hello,

      i have scanned the source of ReactOS with the static code analyis tool cppcheck. It found a resource leak in file ReactOS-0.3.10/base/applications/downloader/xml.c at line 206.

      The tool prints the following output:

      [ReactOS-0.3.10/base/applications/downloader/xml.c:206]: (error) Resource leak: file

      Take a look at file xml.c:

      BOOL ProcessXML (const char* filename, struct Category* Root)
      {
      ...
      FILE* file;
      ...

      file = fopen("downloader.xml", "r");
      if(!file)
      {
      file = fopen(filename, "r");
      if(!file)

      { MessageBoxW(0,Strings[IDS_XMLERROR_1],0,0); return FALSE; }

      }
      ....

      while (!done)
      {
      size_t len = fread (buffer, 1, sizeof(buffer), file);
      done = len < sizeof(buffer);

      if(!XML_Parse(parser, buffer, len, done))

      { MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0); 206 return FALSE; }

      }

      XML_ParserFree(parser);
      fclose(file);

      return TRUE;
      }

      As you can see, at line 206 there is missing fclose(file).

      Best regards

      Ettl Martin

      Attachments

        Issue Links

          Activity

            People

              bug zilla Bug Zilla
              ettl.martin ettl.martin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: