diff options
-rw-r--r-- | coreutils/printf.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c index bc22e0ee7..65bb5a935 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
@@ -305,7 +305,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err) | |||
305 | } | 305 | } |
306 | break; | 306 | break; |
307 | } | 307 | } |
308 | if (strchr("-+ #", *f)) { | 308 | if (*f && strchr("-+ #", *f)) { |
309 | ++f; | 309 | ++f; |
310 | ++direc_length; | 310 | ++direc_length; |
311 | } | 311 | } |
@@ -348,7 +348,7 @@ static char **print_formatted(char *f, char **argv, int *conv_err) | |||
348 | static const char format_chars[] ALIGN1 = "diouxXfeEgGcs"; | 348 | static const char format_chars[] ALIGN1 = "diouxXfeEgGcs"; |
349 | char *p = strchr(format_chars, *f); | 349 | char *p = strchr(format_chars, *f); |
350 | /* needed - try "printf %" without it */ | 350 | /* needed - try "printf %" without it */ |
351 | if (p == NULL) { | 351 | if (p == NULL || *f == '\0') { |
352 | bb_error_msg("%s: invalid format", direc_start); | 352 | bb_error_msg("%s: invalid format", direc_start); |
353 | /* causes main() to exit with error */ | 353 | /* causes main() to exit with error */ |
354 | return saved_argv - 1; | 354 | return saved_argv - 1; |