[script] Avoid trying to read final character of a zero-length string

Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/598/head
Michael Brown 2013-07-15 18:06:41 +02:00
parent 30de9e8300
commit e52c24492a
1 changed files with 2 additions and 2 deletions

View File

@ -92,11 +92,11 @@ static int process_script ( struct image *image,
script_offset += ( frag_len + 1 ); script_offset += ( frag_len + 1 );
/* Strip trailing CR, if present */ /* Strip trailing CR, if present */
if ( line[ len - 1 ] == '\r' ) if ( len && ( line[ len - 1 ] == '\r' ) )
len--; len--;
/* Handle backslash continuations */ /* Handle backslash continuations */
if ( line[ len - 1 ] == '\\' ) { if ( len && ( line[ len - 1 ] == '\\' ) ) {
len--; len--;
rc = -EINVAL; rc = -EINVAL;
continue; continue;