* [Cluster-devel] [fence-virt PATCH] Don't reference out-of-scope temporary
@ 2011-08-24 16:40 Zane Bitter
0 siblings, 0 replies; only message in thread
From: Zane Bitter @ 2011-08-24 16:40 UTC (permalink / raw)
To: cluster-devel.redhat.com
The string on which we were calling c_str() was a temporary, so the C
string returned would no longer be valid. This issue was detected by a
Coverity scan.
Signed-off-by: Zane Bitter <zbitter@redhat.com>
---
server/libvirt-qpid.cpp | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/server/libvirt-qpid.cpp b/server/libvirt-qpid.cpp
index d133346..eb35d49 100644
--- a/server/libvirt-qpid.cpp
+++ b/server/libvirt-qpid.cpp
@@ -120,7 +120,7 @@ int
do_lq_request(struct lq_info *info, const char *vm_name,
const char *action)
{
- const char *vm_state = NULL;
+ std::string vm_state;
const char *property = "name";
if (is_uuid(vm_name) == 1) {
property = "uuid";
@@ -171,15 +171,15 @@ do_lq_request(struct lq_info *info, const char *vm_name,
goto out;
}
- vm_state = domain.getProperty("state").asString().c_str();
+ vm_state = domain.getProperty("state").asString();
std::cout << vm_name << " " << vm_state << std::endl;
int r;
- if (!strcmp( vm_state, "running" ) ||
- !strcmp( vm_state, "idle" ) ||
- !strcmp( vm_state, "paused" ) ||
- !strcmp( vm_state, "no state" ) ) {
+ if (vm_state == "running" ||
+ vm_state == "idle" ||
+ vm_state == "paused" ||
+ vm_state == "no state") {
r = RESP_OFF;
} else {
r = 0;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-08-24 16:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-24 16:40 [Cluster-devel] [fence-virt PATCH] Don't reference out-of-scope temporary Zane Bitter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).