shithub: scc

Download patch

ref: ef6ebfdd2c77c82be5ed3e50e13031d05598f905
parent: 2906c0ed1636c2d72485027f3fa9cb56fe54ba1b
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jul 4 14:54:29 EDT 2013

Fix bug allocating ctype struct

The sizeof was incorrect because we were reserving space for the
pointer, and we should reserve the size for the content.

--- a/types.c
+++ b/types.c
@@ -15,9 +15,9 @@
 struct ctype *
 newctype(void)
 {
-	register struct ctype *tp = xcalloc(sizeof(tp), 1);
+	register struct ctype *tp = xcalloc(sizeof(*tp), 1);
 
-	++tp->refcnt;
+	tp->refcnt = 1;
 	return tp;
 }
 
--