[Plib-devel] [PATCH] ssg/ssgLoadAC.cxx: fix potential crash; accept DOS line endings
Brought to you by:
sjbaker
|
From: Melchior F. <a86...@un...> - 2003-07-02 12:39:45
|
1. add a missing list stopper to avoid potential crashes
2. most of ssgLoadAC.cxx is able to deal with AC files with
DOS line endings, only one line breaks it and leads to
"ac_to_gl: Unrecognised token ''".
do_data():360 discards the expected '\n', which may
actually be a '\r' with the real '\n' coming next and
screwing things up.
Please consider to apply. (And please do also apply my sound
patch from 2003/6/19.)
m.
Index: ssgLoadAC.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssgLoadAC.cxx,v
retrieving revision 1.30
diff -u -p -r1.30 ssgLoadAC.cxx
--- ssgLoadAC.cxx 15 Sep 2002 01:29:11 -0000 1.30
+++ ssgLoadAC.cxx 2 Jul 2003 12:36:25 -0000
@@ -138,6 +138,7 @@ static Tag top_tags [] =
{
{ "MATERIAL", do_material },
{ "OBJECT" , do_object },
+ { NULL, NULL }
} ;
@@ -356,7 +357,12 @@ static int do_data ( char *s )
current_data [ len ] = '\0' ;
- getc ( loader_fd ) ; /* Final RETURN */
+ int c;
+ while ( ( c = getc( loader_fd ) ) != EOF ) /* Final RETURN */
+ if ( c != '\r' && c != '\n' ) {
+ ungetc ( c, loader_fd ) ;
+ break ;
+ }
ssgBranch *br = current_options -> createBranch ( current_data ) ;
|