Mercurial > illumos > illumos-gate
changeset 14153:f1218363a3c7
4062 libscf: memory leaks in scf_simple_app_props_get()
Reviewed by: Jeffry Molanus <jeffry.molanus@nexenta.com>
Reviewed by: Boris Protopopov <boris.protopopov@nexenta.com>
Reviewed by: Andy Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>
author | Marcel Telka <marcel.telka@nexenta.com> |
---|---|
date | Sun, 18 Aug 2013 01:06:16 +0200 |
parents | 46f5fb0b0d36 |
children | 4c227138a4c3 |
files | usr/src/lib/libscf/common/midlevel.c |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/libscf/common/midlevel.c Thu Aug 15 22:33:42 2013 +0200 +++ b/usr/src/lib/libscf/common/midlevel.c Sun Aug 18 01:06:16 2013 +0200 @@ -21,6 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2013 Nexenta Systems, Inc. All rights reserved. */ #include "libscf_impl.h" @@ -1842,11 +1843,14 @@ (pgiter = scf_iter_create(h)) == NULL || (propiter = scf_iter_create(h)) == NULL || (pg = scf_pg_create(h)) == NULL || - (prop = scf_property_create(h)) == NULL) + (prop = scf_property_create(h)) == NULL) { + free(sys_fmri); goto error2; + } if (scf_handle_decode_fmri(h, sys_fmri, NULL, svc, inst, NULL, NULL, SCF_DECODE_FMRI_REQUIRE_INSTANCE) == -1) { + free(sys_fmri); if (scf_error() == SCF_ERROR_CONSTRAINT_VIOLATED) (void) scf_set_error(SCF_ERROR_INVALID_ARGUMENT); goto error2; @@ -1858,6 +1862,7 @@ (pgname = malloc(namelen)) == NULL) { free(thispg); free(ret); + free(sys_fmri); (void) scf_set_error(SCF_ERROR_NO_MEMORY); goto error2; } @@ -2088,6 +2093,9 @@ goto error1; } + if (ret->ap_pglist->pg_name == NULL) + goto error1; + scf_iter_destroy(pgiter); scf_iter_destroy(propiter); scf_pg_destroy(pg); @@ -2099,9 +2107,6 @@ if (local_h) scf_handle_destroy(h); - if (ret->ap_pglist->pg_name == NULL) - return (NULL); - return (ret); /*