svn commit: r264643 - stable/9/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Fri Apr 18 12:34:11 UTC 2014


Author: jilles
Date: Fri Apr 18 12:34:10 2014
New Revision: 264643
URL: http://svnweb.freebsd.org/changeset/base/264643

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

Modified:
  stable/9/bin/sh/var.c
Directory Properties:
  stable/9/bin/sh/   (props changed)

Modified: stable/9/bin/sh/var.c
==============================================================================
--- stable/9/bin/sh/var.c	Fri Apr 18 08:31:55 2014	(r264642)
+++ stable/9/bin/sh/var.c	Fri Apr 18 12:34:10 2014	(r264643)
@@ -339,8 +339,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;


More information about the svn-src-all mailing list