]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r300648
authortruckman <truckman@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 1 Jun 2016 17:33:02 +0000 (17:33 +0000)
committertruckman <truckman@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 1 Jun 2016 17:33:02 +0000 (17:33 +0000)
commit14403c33674d9cecd4f4d92ff22abd480b35f73c
treeadf034f071dd2c950f03231446f2c4dcb742f696
parent17b8edcc6b6b2a0b3ba9efe16bbb3f6c0ac4785f
MFC r300648

Fix CID 1011370 (Resource leak) in ps.

There is no need to to call strdup() on the value returned by fmt().
The latter calls fmt_argv() which always returns a dynamically
allocated string, and calling strdup() on that leaks the memory
allocated by fmt_argv().  Wave some const magic on ki_args and
ki_env to make the direct assignment happy.  This requires a tweak
to the asprintf() case to avoid a const vs. non-const mismatch.

Reported by: Coverity
CID: 1011370

git-svn-id: svn://svn.freebsd.org/base/stable/10@301148 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
bin/ps/ps.c
bin/ps/ps.h