Module Name:    src
Committed By:   christos
Date:           Wed Jul  1 15:34:30 UTC 2015

Modified Files:
        src/usr.bin/xlint/lint1: cgram.y

Log Message:
Fix segmentation fault caused by freeing prematurely function parameter types
inside cast expressions.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/xlint/lint1/cgram.y

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.69 src/usr.bin/xlint/lint1/cgram.y:1.70
--- src/usr.bin/xlint/lint1/cgram.y:1.69	Mon May 11 13:20:06 2015
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Jul  1 11:34:30 2015
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.69 2015/05/11 17:20:06 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.70 2015/07/01 15:34:30 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.69 2015/05/11 17:20:06 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.70 2015/07/01 15:34:30 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1921,8 +1921,10 @@ toicon(tnode_t *tn, int required)
 	/*
 	 * Abstract declarations are used inside expression. To free
 	 * the memory would be a fatal error.
+	 * We don't free blocks that are inside casts because these
+	 * will be used later to match types.
 	 */
-	if (dcs->d_ctx != ABSTRACT)
+	if (tn->tn_op != CON && dcs->d_ctx != ABSTRACT)
 		tfreeblk();
 
 	if ((t = v->v_tspec) == FLOAT || t == DOUBLE || t == LDOUBLE) {

Reply via email to