--- old/usr/src/cmd/svc/svccfg/svccfg_libscf.c Sun May 27 16:50:27 2012 +++ new/usr/src/cmd/svc/svccfg/svccfg_libscf.c Sun May 27 16:50:27 2012 @@ -21,6 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Milan Jurik. All rights reserved. */ @@ -3900,8 +3901,8 @@ pgroup_t *mfst_pgroup; property_t *mfst_prop; property_t *old_prop; - char *pname = malloc(MAXPATHLEN); - char *fval = NULL; + char *pname; + char *fval; char *old_pname; char *old_fval; int no_upgrade_pg; @@ -3971,6 +3972,13 @@ SCF_SUCCESS) return (-1); + if ((pname = malloc(MAXPATHLEN)) == NULL) + return (ENOMEM); + if ((fval = malloc(MAXPATHLEN)) == NULL) { + free(pname); + return (ENOMEM); + } + while ((r = scf_iter_next_property(ud_prop_iter, ud_prop)) == 1) { mfst_seen = 0; if (scf_property_get_name(ud_prop, pname, MAXPATHLEN) < 0) @@ -3990,16 +3998,12 @@ * property list to get proccessed into the repo. */ if (mfst_seen == 0) { - if (fval == NULL) - fval = malloc(MAXPATHLEN); - /* * If we cannot get the value then there is no * reason to attempt to attach the value to * the property group */ - if (fval != NULL && - prop_get_val(ud_prop, fname_value) == 0 && + if (prop_get_val(ud_prop, fname_value) == 0 && scf_value_get_astring(fname_value, fval, MAXPATHLEN) != -1) { old_pname = safe_strdup(pname); @@ -4016,6 +4020,7 @@ } } } + free(pname); free(fval); cbdata.sc_handle = g_hndl;