2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-26 03:09:12 +00:00

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

Detected using Valgrind.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2013-07-15 18:06:41 +02:00
parent 30de9e8300
commit e52c24492a

View File

@ -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;