Fix a small bug when parsing the padding command line argument (-p)

When an empty string was passed as padding spec, this was
not properly flagged as an error.
This commit is contained in:
Thomas Jensen 2021-11-05 14:03:49 +01:00
parent 84d051f1e5
commit eab1e13df2
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB

View File

@ -344,10 +344,11 @@ static int killblank(opt_t *result, char *optarg)
*/
static int padding(opt_t *result, char *optarg)
{
int errfl = 0;
int errfl = 1;
char *p = optarg;
while (*p) {
errfl = 0;
if (p[1] == '\0') {
errfl = 1;
break;
@ -395,7 +396,7 @@ static int padding(opt_t *result, char *optarg)
}
}
if (errfl) {
fprintf(stderr, "%s: invalid padding specification - %s\n", PROJECT, optarg);
bx_fprintf(stderr, "%s: invalid padding specification - %s\n", PROJECT, optarg);
return 1;
}
return 0;