From c7b0882e42cc1dda4956b6016b67e7c1e2381070 Mon Sep 17 00:00:00 2001 From: Bryan Cantrill Date: Wed, 16 May 2012 07:16:44 +0000 Subject: OS-1188 memory leak in restarter_get_method_context() --- usr/src/lib/librestart/common/librestart.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'usr/src/lib/librestart/common/librestart.c') diff --git a/usr/src/lib/librestart/common/librestart.c b/usr/src/lib/librestart/common/librestart.c index 7cf1d30e04..54fcafd6ce 100644 --- a/usr/src/lib/librestart/common/librestart.c +++ b/usr/src/lib/librestart/common/librestart.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ #include @@ -3333,6 +3334,10 @@ restarter_get_method_context(uint_t version, scf_instance_t *inst, * defaults that provide historic init behavior. */ if (mc_used == 0) { + free(cip->pwbuf); + free(cip->vbuf); + free(cip->working_dir); + (void) memset(cip, 0, sizeof (*cip)); cip->uid = 0; cip->gid = 0; @@ -3348,8 +3353,11 @@ out: scf_pg_destroy(instpg); scf_pg_destroy(methpg); - if (cip->pwbuf != NULL) + if (cip->pwbuf != NULL) { free(cip->pwbuf); + cip->pwbuf = NULL; + } + free(cip->vbuf); if (err->type != 0) { -- cgit v1.2.3