Bug 331316

Summary: kde-dev-utils-4.12.2/kmtrace/match.cpp:39]: (error) Resource leak: map_file
Product: [Unmaintained] kmtrace Reporter: dcb314
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: mpyne
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description dcb314 2014-02-20 08:27:35 UTC
Source code is

   while(!feof(map_file))
   {
      fgets(buf, 1024, map_file);
      QString line = QString::fromLatin1(buf).trimmed();
      const QStringList split = line.split(QLatin1Char(' '), QString::SkipEmptyParts);
      if (split.count() <= 1)
         return 1;

Suggest add call to fclose.
Comment 1 dcb314 2014-02-20 12:27:36 UTC
I should also say that I found this bug by using cppcheck, a static analysis tool.

I highly recommend it for C/C++ development work.
Comment 2 Michael Pyne 2014-02-21 03:51:02 UTC
This one's a false positive, as the circumstances of this function call is that it's already running in main(). In other words as soon as we execute "return 1" we're stopping execution anyways and the OS will recover the file descriptor without an fclose() call.

If it were almost any other type of function I'd probably commit a fix just to keep the static analysis tools happy but I can't bring myself to here for what is essentially a documentation change.
Comment 3 Christoph Feck 2017-04-21 16:40:23 UTC
The kmtrace tool is no longer maintained. We suggest you use the 'heaptrack' tool instead.

For more information, please see http://milianw.de/tag/heaptrack