diff options
author | Marcel Telka <marcel.telka@nexenta.com> | 2013-08-18 01:06:16 +0200 |
---|---|---|
committer | Dan McDonald <danmcd@nexenta.com> | 2013-08-21 12:01:51 -0400 |
commit | afffa6e9b45cbe9b33943e26568d8ac69b899252 (patch) | |
tree | 25a37fe33ca72f6927f40238c3dc55ba2bc30ab4 | |
parent | 2fbdf8dbf01ec1c85fcd3827cdf9e9f5f46c4c8a (diff) | |
download | illumos-joyent-afffa6e9b45cbe9b33943e26568d8ac69b899252.tar.gz |
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>
-rw-r--r-- | usr/src/lib/libscf/common/midlevel.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/usr/src/lib/libscf/common/midlevel.c b/usr/src/lib/libscf/common/midlevel.c index 71b72404f1..3037e85113 100644 --- a/usr/src/lib/libscf/common/midlevel.c +++ b/usr/src/lib/libscf/common/midlevel.c @@ -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 @@ scf_simple_app_props_get(scf_handle_t *hin, const char *inst_fmri) (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 @@ scf_simple_app_props_get(scf_handle_t *hin, const char *inst_fmri) (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 @@ scf_simple_app_props_get(scf_handle_t *hin, const char *inst_fmri) 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 @@ scf_simple_app_props_get(scf_handle_t *hin, const char *inst_fmri) if (local_h) scf_handle_destroy(h); - if (ret->ap_pglist->pg_name == NULL) - return (NULL); - return (ret); /* |