develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35405 - trunk/compilers/pirc/src

From:
kjs
Date:
January 11, 2009 04:13
Subject:
[svn:parrot] r35405 - trunk/compilers/pirc/src
Message ID:
20090111121306.C05AFCB9F9@x12.develooper.com
Author: kjs
Date: Sun Jan 11 04:13:05 2009
New Revision: 35405

Modified:
   trunk/compilers/pirc/src/pirsymbol.c

Log:
[pirc] make unused-symbol-checking function slightly safer; if invoked and there's no subroutine object, just return, instead of referencing its attributes, which would result in seg. faults.

Modified: trunk/compilers/pirc/src/pirsymbol.c
==============================================================================
--- trunk/compilers/pirc/src/pirsymbol.c	(original)
+++ trunk/compilers/pirc/src/pirsymbol.c	Sun Jan 11 04:13:05 2009
@@ -276,15 +276,21 @@
 check_unused_symbols(lexer_state * const lexer)>
 
 Check all subroutines for unused symbols. If a symbol is declared but
-never used, a warning message is printed to C<stderr>.
+never used, a warning message is printed to C<stderr>. If there's
+no subroutines, the function will do nothing and return.
 
 =cut
 
 */
 void
 check_unused_symbols(NOTNULL(lexer_state * const lexer)) {
-    subroutine *subiter = lexer->subs->next; /* start at first sub. */
+    subroutine *subiter;
 
+    /* if there's no subs, just return. */
+    if (lexer->subs == NULL)
+        return;
+
+    lexer->subs->next; /* start at first sub. */
     puts("");
 
     do {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About