Date: Wed, 22 May 2019 01:22:33 +0000 (UTC) From: Conrad Meyer <cem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348078 - head/usr.sbin/pmc Message-ID: <201905220122.x4M1MXtx066600@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: cem Date: Wed May 22 01:22:33 2019 New Revision: 348078 URL: https://svnweb.freebsd.org/changeset/base/348078 Log: pmc: Fix stack std::string lifetime It's invalid to reference a C++ string's c_str() buffer after the object goes out of scope. Adjust the scope of the string to match the use in write(2) to fix the misuse. CID: 1393383 Reported by: Coverity Modified: head/usr.sbin/pmc/cmd_pmc_filter.cc Modified: head/usr.sbin/pmc/cmd_pmc_filter.cc ============================================================================== --- head/usr.sbin/pmc/cmd_pmc_filter.cc Wed May 22 01:11:21 2019 (r348077) +++ head/usr.sbin/pmc/cmd_pmc_filter.cc Wed May 22 01:22:33 2019 (r348078) @@ -180,11 +180,12 @@ pmc_find_name(idmap & map, uint32_t id, char *list[LIS static void pmc_log_event(int fd, struct pmclog_ev *ev, bool json) { + string ret; int len; const void *buf; if (json) { - string ret = event_to_json(ev); + ret = event_to_json(ev); buf = ret.c_str(); len = ret.size(); } else {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905220122.x4M1MXtx066600>