[bugfix] double close should be safe

This commit is contained in:
Yuichi Nishiwaki 2015-06-19 01:04:04 +09:00
parent 9263891c4c
commit d1aa42cd7a
1 changed files with 3 additions and 0 deletions

View File

@ -188,6 +188,9 @@ pic_get_output_string(pic_state *pic, struct pic_port *port)
void void
pic_close_port(pic_state *pic, struct pic_port *port) pic_close_port(pic_state *pic, struct pic_port *port)
{ {
if ((port->flags & PIC_PORT_OPEN) == 0) {
return;
}
if (xfclose(port->file) == EOF) { if (xfclose(port->file) == EOF) {
pic_errorf(pic, "close-port: failure"); pic_errorf(pic, "close-port: failure");
} }