Wed Jan 30 20:49:34 CET 2008 Jim Meyering <meyering@redhat.com>
+ Avoid segfault upon malloc failure, and plug a leak.
+ * src/test.c (testDomainSave): Detect testDomainDumpXML failure.
+ Free "xml".
+
Plug test-related leaks.
* src/test.c (testLoadNetwork): Free forwardDev.
(testLoadDomain): Free ctxt.
/*
* test.c: A "mock" hypervisor for use by application unit tests
*
- * Copyright (C) 2006-2007 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
GET_DOMAIN(domain, -1);
xml = testDomainDumpXML(domain, 0);
+ if (xml == NULL) {
+ testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
+ "cannot allocate space for metadata");
+ return (-1);
+ }
if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
if (write(fd, xml, len) != len) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write metadata");
+ free(xml);
close(fd);
return (-1);
}
+ free(xml);
if (close(fd) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot save domain data");