From 538d3d1f4d9ee9fd386b9330454d5c36fe6a1614 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 18 Feb 2008 10:15:59 -0800 Subject: [PATCH] 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. --- vpi/sys_scanf.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index 5b1948431..14a84adf9 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -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);