Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Mar 2014 22:52:27 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263846 - head/bin/sh
Message-ID:  <201403272252.s2RMqRgB025252@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Thu Mar 27 22:52:26 2014
New Revision: 263846
URL: http://svnweb.freebsd.org/changeset/base/263846

Log:
  sh: Fix memory leak when trying to set a read only variable.
  
  MFC after:	1 week

Modified:
  head/bin/sh/var.c

Modified: head/bin/sh/var.c
==============================================================================
--- head/bin/sh/var.c	Thu Mar 27 22:48:48 2014	(r263845)
+++ head/bin/sh/var.c	Thu Mar 27 22:52:26 2014	(r263846)
@@ -325,8 +325,11 @@ setvareq(char *s, int flags)
 		mklocal(s);
 	vp = find_var(s, &vpp, &nlen);
 	if (vp != NULL) {
-		if (vp->flags & VREADONLY)
+		if (vp->flags & VREADONLY) {
+			if ((flags & (VTEXTFIXED|VSTACK)) == 0)
+				ckfree(s);
 			error("%.*s: is read only", vp->name_len, s);
+		}
 		if (flags & VNOSET)
 			return;
 		INTOFF;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403272252.s2RMqRgB025252>