Date: Thu, 5 Jan 2012 23:20:07 GMT From: dfilter@FreeBSD.ORG (dfilter service) To: freebsd-bugs@FreeBSD.org Subject: Re: bin/161510: commit references a PR Message-ID: <201201052320.q05NK7J0063120@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/161510; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/161510: commit references a PR Date: Thu, 5 Jan 2012 23:10:18 +0000 (UTC) Author: ghelmer Date: Thu Jan 5 23:08:11 2012 New Revision: 229668 URL: http://svn.freebsd.org/changeset/base/229668 Log: Fix a memory leak in addgroup() by ensuring the allocated memory is freed if an error occurs. PR: bin/161510 MFC after: 4 weeks Modified: head/usr.bin/newgrp/newgrp.c Modified: head/usr.bin/newgrp/newgrp.c ============================================================================== --- head/usr.bin/newgrp/newgrp.c Thu Jan 5 22:48:36 2012 (r229667) +++ head/usr.bin/newgrp/newgrp.c Thu Jan 5 23:08:11 2012 (r229668) @@ -190,7 +190,7 @@ addgroup(const char *grpname) err(1, "malloc"); if ((ngrps = getgroups(ngrps_max, (gid_t *)grps)) < 0) { warn("getgroups"); - return; + goto end; } /* Remove requested gid from supp. list if it exists. */ @@ -204,7 +204,7 @@ addgroup(const char *grpname) if (setgroups(ngrps, (const gid_t *)grps) < 0) { PRIV_END; warn("setgroups"); - return; + goto end; } PRIV_END; } @@ -213,7 +213,7 @@ addgroup(const char *grpname) if (setgid(grp->gr_gid)) { PRIV_END; warn("setgid"); - return; + goto end; } PRIV_END; grps[0] = grp->gr_gid; @@ -228,12 +228,12 @@ addgroup(const char *grpname) if (setgroups(ngrps, (const gid_t *)grps)) { PRIV_END; warn("setgroups"); - return; + goto end; } PRIV_END; } } - +end: free(grps); } _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201052320.q05NK7J0063120>