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>
This commit is contained in:
Yi-Yo Chiang 2021-04-14 22:10:27 +08:00 committed by James Carter
parent 1e4e7f6a12
commit d1a34d3f1d

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) {