Don't reference out-of-scope temporary
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> Reviewed-by: Lon Hohberger <lon@users.sourceforge.net>
This commit is contained in:
parent
53a2b293d1
commit
b5e1bc6e5f
@ -120,7 +120,7 @@ int
|
|||||||
do_lq_request(struct lq_info *info, const char *vm_name,
|
do_lq_request(struct lq_info *info, const char *vm_name,
|
||||||
const char *action)
|
const char *action)
|
||||||
{
|
{
|
||||||
const char *vm_state = NULL;
|
std::string vm_state;
|
||||||
const char *property = "name";
|
const char *property = "name";
|
||||||
if (is_uuid(vm_name) == 1) {
|
if (is_uuid(vm_name) == 1) {
|
||||||
property = "uuid";
|
property = "uuid";
|
||||||
@ -171,15 +171,15 @@ do_lq_request(struct lq_info *info, const char *vm_name,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm_state = domain.getProperty("state").asString().c_str();
|
vm_state = domain.getProperty("state").asString();
|
||||||
|
|
||||||
std::cout << vm_name << " " << vm_state << std::endl;
|
std::cout << vm_name << " " << vm_state << std::endl;
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
if (!strcmp( vm_state, "running" ) ||
|
if (vm_state == "running" ||
|
||||||
!strcmp( vm_state, "idle" ) ||
|
vm_state == "idle" ||
|
||||||
!strcmp( vm_state, "paused" ) ||
|
vm_state == "paused" ||
|
||||||
!strcmp( vm_state, "no state" ) ) {
|
vm_state == "no state") {
|
||||||
r = RESP_OFF;
|
r = RESP_OFF;
|
||||||
} else {
|
} else {
|
||||||
r = 0;
|
r = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user