Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 08 Oct 2015 19:04:28 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 203647] makefs: Coverity CID 978431: No free() after malloc().
Message-ID:  <bug-203647-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203647

            Bug ID: 203647
           Summary: makefs: Coverity CID 978431: No free() after malloc().
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: scdbackup@gmx.net

usr.sbin/makefs/cd9660/cd9660_write.c

CID 978431: Resource leak (RESOURCE_LEAK)
   9. leaked_storage: Variable buffer going out of scope leaks the
   storage it points to.

216        return cd9660_write_filedata(fd, sector, buffer_head,
217            path_table_sectors);

--------------- Source analysis:

There are two return statements in the function.
The first one (return 0) is ok, because malloc() returned NULL.
The second one uses the allocated buffer and does not free it.

--------------- Remedy proposal:

Untangle the return statement.

-        return cd9660_write_filedata(fd, sector, buffer_head,
+        ret = cd9660_write_filedata(fd, sector, buffer_head,
              path_table_sectors);
+        free(buffer);
+        return ret;

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-203647-8>