Slono Slono
2011-Nov-18 00:05 UTC
memory leaks (and some other warning like divison by zero; ) auto reports for FreeBSD source code
Hi This information can be interesting - in most cases really doesn't suffice free() and someone is necessary with commit bit who it can to correct. reported by cppcheck (http://cppcheck.sourceforge.net/): This report is actual for FreeBSD 9.0-PRERELEASE Scan for /usr/src/libexec/: [rtld-elf/rtld.c:1660]: (error) Resource leak: fd [ftpd/ftpd.c:610]: (error) Mismatching allocation and deallocation: fd Scan for /usr/src/lib/ [libarchive/archive_entry_link_resolver.c:240]: (error) Memory leak: le [libarchive/archive_read_open_filename.c:115]: (error) Resource leak: fd [libarchive/archive_read_support_format_tar.c:638]: (error) Buffer access out-of-bounds: header.magic [libarchive/archive_write_disk.c:1767]: (error) Memory leak: le [libc/db/test/btree.tests/main.c:601]: (error) Resource leak: fp [libc/gen/_pthread_stubs.c:218]: (error) Analysis failed. If the code is valid then please report this failure. [libc/mips/gen/makecontext.c:107]: (error) Uninitialized variable: i [libc/net/getifaddrs.c:250]: (error) Invalid deallocation [libc/net/getifaddrs.c:255]: (error) Invalid deallocation [libc/net/nscache.c:118]: (error) Common realloc mistake: 'buffer' nulled but not freed upon failure [libc/net/nscache.c:204]: (error) Common realloc mistake: 'buffer' nulled but not freed upon failure [libc/net/nscache.c:299]: (error) Common realloc mistake: 'buffer' nulled but not freed upon failure [libc/net/nscache.c:375]: (error) Common realloc mistake: 'buffer' nulled but not freed upon failure [libc/quad/qdivrem.c:100]: (error) Division by zero [libc/rpc/clnt_perror.c:301]: (error) Allocation with clnt_spcreateerror, fprintf doesn't release it. [libc/rpc/netnamer.c:331]: (error) Resource leak: fd [libdisk/open_disk.c:89]: (error) Memory leak: d [libdwarf/dwarf_attr.c:49]: (error) Possible null pointer dereference: at - otherwise it is redundant to check if at is null at line 54 [libdwarf/dwarf_init.c:505]: (error) Memory leak: cu [libedit/readline.c:1009]: (error) Possible null pointer dereference: arr - otherwise it is redundant to check if arr is null at line 1006 [libedit/readline.c:1693]: (error) Possible null pointer dereference: pwd - otherwise it is redundant to check if pwd is null at line 1695 [libedit/readline.c:1934]: (error) Memory leak: wbuf [libfetch/file.c:148]: (error) Resource leak: dir [libgssapi/gss_accept_sec_context.c:217]: (error) Possible null pointer dereference: mc - otherwise it is redundant to check if mc is null at line 219 [libgssapi/gss_accept_sec_context.c:220]: (error) Memory leak: ctx [libgssapi/gss_inquire_cred_by_mech.c:68]: (error) Possible null pointer dereference: mcp - otherwise it is redundant to check if mcp is null at line 70 [libgssapi/gss_verify_mic.c:42]: (error) Possible null pointer dereference: ctx - otherwise it is redundant to check if ctx is null at line 46 [libgssapi/gss_wrap_size_limit.c:43]: (error) Possible null pointer dereference: ctx - otherwise it is redundant to check if ctx is null at line 46 [libjail/jail_getid.c:103]: (error) Uninitialized variable: namebuf [libmd/mdXhl.c:63]: (error) Resource leak: f [libncp/ncpl_conn.c:495]: (error) Resource leak: d [libncp/ncpl_file.c:89]: (error) Resource leak: d [libprocstat/libprocstat.c:723]: (error) Memory leak: path [librt/timer.c:106]: (error) Memory leak: timer [libstand/bzipfs.c:194]: (error) Resource leak: rawfd [libstand/qdivrem.c:99]: (error) Division by zero Scan for /usr/src/bin/: [ps/print.c:427]: (error) Memory leak: buf [ps/print.c:457]: (error) Memory leak: buf [sh/jobs.c:825]: (error) Allocation with open, if doesn't release it. [sh/mknodes.c:269]: (error) Resource leak: hfile [sh/mknodes.c:269]: (error) Resource leak: patfile [pax/cache.c:333]: (error) Possible null pointer dereference: ptr - otherwise it is redundant to check if ptr is null at line 345 [pax/cache.c:397]: (error) Possible null pointer dereference: ptr - otherwise it is redundant to check if ptr is null at line 408 Scan for /usr/src/cddl/: contrib/opensolaris/cmd/dtrace/test/cmd/baddof/baddof.c:202]: (error) Deallocating a deallocated pointer: fd [contrib/opensolaris/cmd/lockstat/sym.c:150]: (error) Memory leak: name [contrib/opensolaris/cmd/sgs/tools/common/sgsmsg.c:311]: (error) Memory leak: buffer [contrib/opensolaris/cmd/sgs/tools/common/sgsmsg.c:503]: (error) Memory leak: buf [contrib/opensolaris/cmd/sgs/tools/common/sgsmsg.c:950]: (error) Common realloc mistake: 'token_buffer' nulled but not freed upon failure [contrib/opensolaris/cmd/zpool/zpool_main.c:4622]: (error) Resource leak: fd [contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c:568]: (error) Memory leak: percpu [contrib/opensolaris/lib/libdtrace/common/dt_cc.c:2117]: (error) Resource leak: dirp [contrib/opensolaris/lib/libdtrace/common/dt_link.c:1735]: (error) Resource leak: fd [contrib/opensolaris/lib/libdtrace/common/dt_strtab.c:257]: (error) Memory leak: hp [contrib/opensolaris/lib/libzfs/common/libzfs_import.c:1006]: (error) Dangerous usage of 'diskname' (strncpy doesn't always 0-terminate it) [contrib/opensolaris/tools/ctf/cvt/dwarf.c:503]: (error) Possible null pointer dereference: loc - otherwise it is redundant to check if loc is null at line 505 Scan for /usr/src/usr.bin/: [column/column.c:272]: (error) Memory leak: lens [cpio/cmdline.c:348]: (error) Memory leak: user [csup/updater.c:1905]: (error) Resource leak: fd [csup/updater.c:1988]: (error) Resource leak: orig [elf2aout/elf2aout.c:154]: (error) Resource leak: fd [env/envopts.c:467]: (error) Memory leak: newstr [finger/lprint.c:306]: (error) Resource leak: fd [grep/regex/tre-fastmatch.c:534]: (error) Memory leak: p [grep/regex/tre-fastmatch.c:537]: (error) Memory leak: wp [grep/regex/tre-fastmatch.c:766]: (error) Memory leak: p [grep/regex/tre-fastmatch.c:769]: (error) Memory leak: wp [gzip/gzip.c:1272]: (error) Resource leak: in [join/join.c:495]: (error) Possible null pointer dereference: olist - otherwise it is redundant to check if olist is null at line 485 [last/last.c:283]: (error) Possible null pointer dereference: tt - otherwise it is redundant to check if tt is null at line 286 [login/login.c:624]: (error) Memory leak: cx [m4/main.c:643]: (error) Common realloc mistake: 'sstack' nulled but not freed upon failure [make/var.c:1764]: (error) Uninitialized variable: error [makewhatis/makewhatis.c:351]: (error) Resource leak: output [msgs/msgs.c:804]: (error) Resource leak: cpfrom [newkey/update.c:273]: (error) Resource leak: rf [newkey/update.c:320]: (error) Memory leak: tmpname [pr/pr.c:211]: (error) Memory leak: obuf [pr/pr.c:362]: (error) Memory leak: buf [pr/pr.c:383]: (error) Memory leak: vc [pr/pr.c:395]: (error) Memory leak: indy [pr/pr.c:669]: (error) Memory leak: buf [sed/compile.c:842]: (error) Memory leak: p [showmount/showmount.c:332]: (error) Memory leak: ep [showmount/showmount.c:341]: (error) Memory leak: gp [tip/tip/cmds.c:129]: (error) Resource leak: fd [truss/amd64-fbsd.c:214]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 218 [truss/amd64-fbsd32.c:217]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 221 [truss/amd64-linux32.c:187]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 191 [truss/i386-fbsd.c:207]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 211 [truss/i386-linux.c:187]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 191 [truss/ia64-fbsd.c:189]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 193 [truss/mips-fbsd.c:234]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 238 [truss/powerpc-fbsd.c:221]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 225 [truss/powerpc64-fbsd.c:209]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 213 [truss/sparc64-fbsd.c:232]: (error) Possible null pointer dereference: sc - otherwise it is redundant to check if sc is null at line 236 [truss/syscalls.c:518]: (error) Common realloc mistake: 'buf' nulled but not freed upon failure [tset/wrterm.c:114]: (error) Memory leak: sep [unvis/unvis.c:69]: (error) Resource leak: fp [vgrind/vgrindefs.c:119]: (error) Resource leak: tf [vgrind/vgrindefs.c:150]: (error) Possible null pointer dereference: q - otherwise it is redundant to check if q is null at line 148 [vis/vis.c:112]: (error) Resource leak: fp [yacc/lr0.c:289]: (error) The given size 102 is mismatching Scan for /usr/src/usr.sbin: [acpi/acpidb/acpidb.c:373]: (error) Resource leak: fd [acpi/acpidump/acpi.c:1199]: (error) Dangerous usage of 'tmpstr' (strncpy doesn't always 0-terminate it) [asf/asf.c:186]: (error) Resource leak: objcopy [asf/asf_prog.c:73]: (error) Resource leak: kldstat [bluetooth/bt3cfw/bt3cfw.c:225]: (error) Resource leak: firmware_file [boot0cfg/boot0cfg.c:337]: (error) Resource leak: fd [bootparamd/bootparamd/bootparamd.c:239]: (error) Resource leak: bpf [bsdinstall/distextract/distextract.c:52]: (error) Memory leak: diststring [bsdinstall/distfetch/distfetch.c:51]: (error) Memory leak: diststring [bsdinstall/partedit/gpart_ops.c:1218]: (error) Possible null pointer dereference: cp - otherwise it is redundant to check if cp is null at line 1222 [bsdinstall/partedit/gpart_ops.c:307]: (error) Resource leak: bootfd [bsdinstall/partedit/gpart_ops.c:950]: (error) Possible null pointer dereference: gc - otherwise it is redundant to check if gc is null at line 952 [bsdinstall/partedit/part_wizard.c:136]: (error) Undefined behavior: variable is used as parameter and destination in s[n]printf(). [bsdinstall/partedit/part_wizard.c:182]: (error) Possible null pointer dereference: pp - otherwise it is redundant to check if pp is null at line 185 [bsdinstall/partedit/part_wizard.c:206]: (error) Possible null pointer dereference: classp - otherwise it is redundant to check if classp is null at line 209 [bsdinstall/partedit/partedit.c:202]: (error) Possible null pointer dereference: md - otherwise it is redundant to check if md is null at line 205 [bsnmpd/modules/snmp_bridge/bridge_sys.c:1249]: (error) Possible null pointer dereference: bp - otherwise it is redundant to check if bp is null at line 1247 [bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c:161]: (error) Possible null pointer dereference: map - otherwise it is redundant to check if map is null at line 164 [bsnmpd/modules/snmp_hostres/hostres_network_tbl.c:182]: (error) Possible null pointer dereference: net - otherwise it is redundant to check if net is null at line 185 [bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c:172]: (error) Possible null pointer dereference: map - otherwise it is redundant to check if map is null at line 175 [bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c:150]: (error) Possible null pointer dereference: map - otherwise it is redundant to check if map is null at line 153 [bsnmpd/tools/libbsnmptools/bsnmptools.c:1084]: (error) Invalid deallocation [config/main.c:506]: (error) Memory leak: p [config/main.c:516]: (error) Allocation with path, moveifchanged doesn't release it. [config/main.c:612]: (error) Allocation with path, unlink doesn't release it. [config/mkmakefile.c:685]: (error) Memory leak: suff [config/mkoptions.c:190]: (error) Possible null pointer dereference: ol - otherwise it is redundant to check if ol is null at line 227 [config/mkoptions.c:220]: (error) Possible null pointer dereference: ol - otherwise it is redundant to check if ol is null at line 227 [config/mkoptions.c:382]: (error) Memory leak: this [cron/lib/compat.c:235]: (error) Memory leak: tmp [crunch/crunchgen/crunchgen.c:733]: (error) Mismatching allocation and deallocation: f [ctm/ctm/ctm_input.c:90]: (error) Memory leak: p [edquota/edquota.c:558]: (error) Resource leak: fd [edquota/edquota.c:736]: (error) Resource leak: fd [faithd/faithd.c:633]: (error) Invalid number of character (() when these macros are defined: ''. [faithd/faithd.c:633]: (error) Invalid number of character (() when these macros are defined: 'HAVE_POLL_H'. [faithd/faithd.c:633]: (error) Invalid number of character (() when these macros are defined: 'IPV6_FAITH'. [faithd/faithd.c:633]: (error) Invalid number of character (() when these macros are defined: 'IPV6_V6ONLY'. [faithd/faithd.c:633]: (error) Invalid number of character (() when these macros are defined: 'SA_NOCLDWAIT'. [faithd/faithd.c:633]: (error) Invalid number of character (() when these macros are defined: '__KAME__'. [fdcontrol/fdcontrol.c:208]: (error) Resource leak: fd [fdformat/fdformat.c:290]: (error) Resource leak: fd [fdread/fdread.c:295]: (error) Memory leak: trackbuf [fifolog/lib/fifolog_create.c:121]: (error) Resource leak: fd [fwcontrol/fwcontrol.c:154]: (error) Possible null pointer dereference: data - otherwise it is redundant to check if data is null at line 155 [kbdcontrol/kbdcontrol.c:163]: (error) Common realloc mistake: 'buf' nulled but not freed upon failure [lpr/common_source/common.c:186]: (error) Memory leak: q [lpr/common_source/ctlinfo.c:294]: (error) Resource leak: cfile [lpr/lpd/lpd.c:423]: (error) Resource leak: lfd [lpr/lpd/printjob.c:653]: (error) Dereferencing 'fi' after it is deallocated / released [makefs/cd9660.c:2038]: (error) Memory leak: temp [makefs/cd9660.c:2065]: (error) Memory leak: temp [makefs/cd9660.c:701]: (error) Array 'record.ext_attr_length[0]' index 0 out of bounds [makefs/cd9660/cd9660_eltorito.c:233]: (error) Memory leak: temp [makefs/compat/pwcache.c:391]: (error) Possible null pointer dereference: ptr - otherwise it is redundant to check if ptr is null at line 404 [makefs/compat/pwcache.c:455]: (error) Possible null pointer dereference: ptr - otherwise it is redundant to check if ptr is null at line 468 [mixer/mixer.c:183]: (error) Resource leak: baz [mlxcontrol/command.c:580]: (error) Resource leak: fd [mlxcontrol/command.c:634]: (error) Resource leak: fd [mlxcontrol/interface.c:103]: (error) Resource leak: ctrlfd [mlxcontrol/interface.c:262]: (error) Assigning address of local auto-variable to a function parameter. [mlxcontrol/interface.c:263]: (error) Assigning address of local auto-variable to a function parameter. [mlxcontrol/interface.c:264]: (error) Assigning address of local auto-variable to a function parameter. [mptutil/mpt_config.c:113]: (error) Resource leak: vfd [mptutil/mpt_config.c:129]: (error) Resource leak: dfd [mptutil/mpt_config.c:713]: (error) Memory leak: info [ndiscvt/ndiscvt.c:215]: (error) Memory leak: outfile [newsyslog/newsyslog.c:1950]: (error) Possible null pointer dereference: zwork - otherwise it is redundant to check if zwork is null at line 1951 [ngctl/main.c:205]: (error) Resource leak: fp [pciconf/pciconf.c:645]: (error) Resource leak: fd [pciconf/pciconf.c:664]: (error) Resource leak: fd [pkg_install/lib/exec.c:50]: (error) Memory leak: cmd [pkg_install/lib/exec.c:79]: (error) Memory leak: rp [pkg_install/lib/plist.c:592]: (error) Memory leak: cp1 [pkg_install/lib/url.c:115]: (error) Resource leak: pkgfd [pkg_install/updating/main.c:125]: (error) Possible null pointer dereference: curr - otherwise it is redundant to check if curr is null at line 122 [pkg_install/updating/main.c:126]: (error) Possible null pointer dereference: curr - otherwise it is redundant to check if curr is null at line 122 [pkg_install/updating/main.c:220]: (error) Memory leak: dateline [pmcstat/pmcstat_log.c:862]: (error) Possible null pointer dereference: pcm - otherwise it is redundant to check if pcm is null at line 865 [ppp/lqr.c:204]: (error) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 207 [pwd_mkdb/pwd_mkdb.c:710]: (error) Resource leak: from_fd [pwd_mkdb/pwd_mkdb.c:710]: (error) Resource leak: to_fd [rpc.ypupdated/update.c:270]: (error) Resource leak: rf [rpc.ypupdated/update.c:317]: (error) Memory leak: tmpname [rpcbind/rpcb_svc_com.c:414]: (error) Resource leak: fd [rpcbind/rpcbind.c:661]: (error) Memory leak: pml [rtadvd/advcap.c:169]: (error) Resource leak: tf [sade/dmenu.c:120]: (error) Memory leak: var [sade/label.c:1231]: (error) Possible null pointer dereference: pi - otherwise it is redundant to check if pi is null at line 1233 [services_mkdb/uniq.c:126]: (error) Memory leak: cline [sicontrol/sicontrol.c:243]: (error) Memory leak: acp [sysinstall/config.c:426]: (error) Resource leak: rcSite [sysinstall/dispatch.c:465]: (error) Memory leak: list [sysinstall/dispatch.c:518]: (error) Memory leak: list [sysinstall/dispatch.c:562]: (error) Common realloc mistake: 'menu' nulled but not freed upon failure [sysinstall/dispatch.c:653]: (error) Memory leak: list [sysinstall/dmenu.c:160]: (error) Memory leak: var [sysinstall/index.c:715]: (error) Possible null pointer dereference: id - otherwise it is redundant to check if id is null at line 719 [sysinstall/label.c:1217]: (error) Possible null pointer dereference: pi - otherwise it is redundant to check if pi is null at line 1219 [sysinstall/media.c:538]: (error) Memory leak: ufsDevice.private [sysinstall/modules.c:168]: (error) Common realloc mistake: 'menu' nulled but not freed upon failure [sysinstall/modules.c:194]: (error) Possible null pointer dereference: menu [sysinstall/modules.c:204]: (error) Resource leak: dir [sysinstall/tcpip.c:284]: (error) Mismatching allocation and deallocation: ifp [sysinstall/tcpip.c:339]: (error) Mismatching allocation and deallocation: ifp [tzsetup/tzsetup.c:609]: (error) Resource leak: fd1 [tzsetup/tzsetup.c:627]: (error) Resource leak: fd2 [ypserv/yp_dnslookup.c:516]: (error) Memory leak: q [ypserv/yp_main.c:364]: (error) Memory leak: sname PS: Other catalogs as contrib, sys weren't checked - probably and it makes sense