secilc.c: Don't fail if input file is empty

fread(3) returns zero if |size| is zero. This confuses secilc, and
causes it to fail with a "Failure reading file" error, even though there
is no error.

Add a shortcut that closes and skips an input file if file size is zero.

Signed-off-by: Yi-Yo Chiang <yochiang@google.com>
Change-Id: I9832c62ebf6f716235e871b5e29b0fd70c94b453
This commit is contained in:
Yi-Yo Chiang 2021-04-14 22:10:27 +08:00 committed by Jeff Vander Stoep
parent 0c40b2bbcf
commit ff3c99978a

View file

@ -268,6 +268,12 @@ int main(int argc, char *argv[])
}
file_size = filedata.st_size;
if (!file_size) {
fclose(file);
file = NULL;
continue;
}
buffer = malloc(file_size);
rc = fread(buffer, file_size, 1, file);
if (rc != 1) {