|
@@ -45,13 +45,16 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
45
|
45
|
*/
|
46
|
46
|
static int imgfill_cmdline ( struct image *image, unsigned int nargs,
|
47
|
47
|
char **args ) {
|
48
|
|
- size_t len;
|
|
48
|
+ size_t len = 0;
|
49
|
49
|
unsigned int i;
|
50
|
50
|
|
|
51
|
+ /* Clear command line if no arguments given */
|
|
52
|
+ if ( ! nargs )
|
|
53
|
+ return image_set_cmdline ( image, NULL );
|
|
54
|
+
|
51
|
55
|
/* Determine total length of command line */
|
52
|
|
- len = 1; /* NUL */
|
53
|
56
|
for ( i = 0 ; i < nargs ; i++ )
|
54
|
|
- len += ( 1 /* possible space */ + strlen ( args[i] ) );
|
|
57
|
+ len += ( strlen ( args[i] ) + 1 /* space or NUL */ );
|
55
|
58
|
|
56
|
59
|
{
|
57
|
60
|
char buf[len];
|