From: Jim Meyering Date: Wed, 30 Jan 2008 19:54:29 +0000 (+0000) Subject: Avoid used-uninitialized errors in test driver. X-Git-Tag: LIBVIRT_0_4_1~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1217e5d5161a018bdae3ea33b5bdcff803c3434f;p=thirdparty%2Flibvirt.git Avoid used-uninitialized errors in test driver. * src/test.c (testOpenFromFile): Initialize "privconn". --- diff --git a/ChangeLog b/ChangeLog index 41629f032d..f91591533d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ Wed Jan 30 20:49:34 CET 2008 Jim Meyering + Avoid used-uninitialized errors in test driver. + * src/test.c (testOpenFromFile): Initialize "privconn". + * src/libvirt.c (do_open): Avoid double-free upon failure. Avoid segfault upon malloc failure, and plug a leak. diff --git a/src/test.c b/src/test.c index 85170d9961..fe5da41f11 100644 --- a/src/test.c +++ b/src/test.c @@ -672,7 +672,7 @@ static int testOpenFromFile(virConnectPtr conn, xmlNodePtr *domains, *networks = NULL; xmlXPathContextPtr ctxt = NULL; virNodeInfoPtr nodeInfo; - testConnPtr privconn = malloc(sizeof(*privconn)); + testConnPtr privconn = calloc(1, sizeof(*privconn)); if (!privconn) { testError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "testConn"); return VIR_DRV_OPEN_ERROR;