Print an error message if $fscanf() is called with a NULL fd.

If $fscanf() is called with a NULL file descriptor an appropriate
error message is printed and the program exits.
This commit is contained in:
Cary R 2008-02-18 10:15:59 -08:00 committed by Stephen Williams
parent 528af27769
commit 538d3d1f4d
1 changed files with 6 additions and 0 deletions

View File

@ -528,6 +528,12 @@ static PLI_INT32 sys_fscanf_calltf(PLI_BYTE8*name)
val.format = vpiIntVal;
vpi_get_value(item, &val);
if (val.value.integer == 0) {
vpi_printf("%s:%d: Error: $fscanf called with NULL file "
"descriptor.\n", vpi_get_str(vpiFile, sys),
(int)vpi_get(vpiLineNo, sys));
exit(1);
}
fd = vpi_get_file(val.value.integer);
assert(fd);