mirror of https://github.com/ipxe/ipxe.git
Explicitly print out-of-memory message to avoid tricking the user into
thinking that a command executed successfully.pull/1/head
parent
22289ca8f6
commit
b613086bfe
|
@ -85,7 +85,7 @@ char * readline ( const char *prompt ) {
|
||||||
.cursor = 0,
|
.cursor = 0,
|
||||||
};
|
};
|
||||||
int key;
|
int key;
|
||||||
char *line = NULL;
|
char *line;
|
||||||
|
|
||||||
if ( prompt )
|
if ( prompt )
|
||||||
printf ( "%s", prompt );
|
printf ( "%s", prompt );
|
||||||
|
@ -97,17 +97,17 @@ char * readline ( const char *prompt ) {
|
||||||
switch ( key ) {
|
switch ( key ) {
|
||||||
case 0x0d: /* Carriage return */
|
case 0x0d: /* Carriage return */
|
||||||
case 0x0a: /* Line feed */
|
case 0x0a: /* Line feed */
|
||||||
|
putchar ( '\n' );
|
||||||
line = strdup ( buf );
|
line = strdup ( buf );
|
||||||
goto out;
|
if ( ! line )
|
||||||
|
printf ( "Out of memory\n" );
|
||||||
|
return line;
|
||||||
case 0x03: /* Ctrl-C */
|
case 0x03: /* Ctrl-C */
|
||||||
goto out;
|
putchar ( '\n' );
|
||||||
|
return NULL;
|
||||||
default:
|
default:
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
putchar ( '\n' );
|
|
||||||
return line;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue