svn commit: r348078 - head/usr.sbin/pmc
Conrad Meyer
cem at FreeBSD.org
Wed May 22 01:22:34 UTC 2019
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 {
More information about the svn-src-all
mailing list