This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[JAVA] Avoid segfault invoking jc1 with no args


The following patch prevents jc1 from dumping core when executed
with no command line arguments.  The problem is that java_parse_file
doesn't consider the eventuality that input_filename is NULL, which
currently results in an ICE in xstrdup.

Ok for mainline?


2004-02-28  Roger Sayle  <roger@eyesopen.com>

	* jcf-parse.c (java_parse_file): Handle the case that input_filename
	is NULL.


Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.157
diff -c -3 -p -r1.157 jcf-parse.c
*** jcf-parse.c	16 Jan 2004 17:11:08 -0000	1.157
--- jcf-parse.c	28 Feb 2004 21:55:41 -0000
*************** java_parse_file (int set_yydebug ATTRIBU
*** 910,918 ****
        finput = NULL;
      }
    else
!     list = xstrdup (input_filename);

!   do
      {
        for (next = list; ; )
  	{
--- 910,918 ----
        finput = NULL;
      }
    else
!     list = input_filename ? xstrdup (input_filename) : 0;

!   while (list)
      {
        for (next = list; ; )
  	{
*************** java_parse_file (int set_yydebug ATTRIBU
*** 991,997 ****
  	}
        list = next;
      }
-   while (next);

    if (filename_count == 0)
      warning ("no input file specified");
--- 991,996 ----


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]