I found another bug, in Plan 9 "grap" source file print.c,
function "opentemp": if tfd is not NULL and also not stdout,
it gets fclose()d twice. I don't know whether that happens
to be benign on the Plan 9 implementation, but it can cause
problems when ported to other platforms.
Also in the same file, in the "print" function, if tfd is
stdout then stdout is fclose()d but later continues to be
used.
I'm not sure of the intent of this change from an earlier
version of "grap"; however, I suggest the following patches
to src/grap/print.c:
In print(), change the test to
if (tfd != stdout) {
if (tfd != NULL)
fclose(tfd); /* end the temp file */
tfd = stdout;
}
In opentemp(), delete the first occurrence of
if (tfd != NULL)
fclose(tfd);