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: [email protected]
          Reporter: [email protected]

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.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to