comparison gui/skin/font.c @ 30404:5fbb30fa62cc

Fix newline removal code that might read and write out of bounds.
author reimar
date Wed, 27 Jan 2010 19:42:24 +0000
parents 0f1b5b68af32
children d39acea63f2e
comparison
equal deleted inserted replaced
30403:22633d3fbffe 30404:5fbb30fa62cc
85 85
86 while ( !feof( f ) ) 86 while ( !feof( f ) )
87 { 87 {
88 fgets( tmp,255,f ); linenumber++; 88 fgets( tmp,255,f ); linenumber++;
89 89
90 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0; 90 // remove any kind of newline, if any
91 c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0; 91 tmp[strcspn(tmp, "\n\r")] = 0;
92 for ( c=0;c < (int)strlen( tmp );c++ ) 92 for ( c=0;c < (int)strlen( tmp );c++ )
93 if ( tmp[c] == ';' ) { tmp[c]=0; break; } 93 if ( tmp[c] == ';' ) { tmp[c]=0; break; }
94 if ( !tmp[0] ) continue; 94 if ( !tmp[0] ) continue;
95 ptmp=trimleft( tmp ); 95 ptmp=trimleft( tmp );
96 if ( !tmp[0] ) continue; 96 if ( !tmp[0] ) continue;