Skip to content

Commit

Permalink
[script] Avoid trying to read final character of a zero-length string
Browse files Browse the repository at this point in the history
Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 15, 2013
1 parent 30de9e8 commit e52c244
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/image/script.c
Expand Up @@ -92,11 +92,11 @@ static int process_script ( struct image *image,
script_offset += ( frag_len + 1 );

/* Strip trailing CR, if present */
if ( line[ len - 1 ] == '\r' )
if ( len && ( line[ len - 1 ] == '\r' ) )
len--;

/* Handle backslash continuations */
if ( line[ len - 1 ] == '\\' ) {
if ( len && ( line[ len - 1 ] == '\\' ) ) {
len--;
rc = -EINVAL;
continue;
Expand Down

0 comments on commit e52c244

Please sign in to comment.