Bug 331316 - kde-dev-utils-4.12.2/kmtrace/match.cpp:39]: (error) Resource leak: map_file
Summary: kde-dev-utils-4.12.2/kmtrace/match.cpp:39]: (error) Resource leak: map_file
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kmtrace
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-20 08:27 UTC by dcb314
Modified: 2017-04-21 16:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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