code: drawterm

Download patch

ref: d4753beb37afbe0575fbe4f27ffec5117cd43424
parent: 353f9089e69e48fb66767b725cce6b438cb40668
author: Russ Cox <rsc@swtch.com>
date: Wed Oct 11 23:21:03 EDT 2006

dangling pointer reference (Tim Wiess)

--- a/kern/devmnt.c
+++ b/kern/devmnt.c
@@ -220,9 +220,6 @@
 	m->msize = f.msize;
 	unlock(&mntalloc.lk);
 
-	poperror();	/* msg */
-	free(msg);
-
 	lock(&m->lk);
 	m->queue = 0;
 	m->rip = 0;
@@ -232,16 +229,19 @@
 	m->c = c;
 	unlock(&m->lk);
 
+	poperror();	/* msg */
 	poperror();	/* c */
 	qunlock(&c->umqlock);
 
 	k = strlen(f.version);
 	if(returnlen > 0){
-		if(returnlen < k)
+		if(returnlen < k){
+			free(msg);
 			error(Eshort);
+		}
 		memmove(version, f.version, k);
 	}
-
+	free(msg);
 	return k;
 }