From d1aa42cd7aa4c3277bf95f84e6f9c4a436bef1cf Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 19 Jun 2015 01:04:04 +0900 Subject: [PATCH] [bugfix] double close should be safe --- extlib/benz/port.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extlib/benz/port.c b/extlib/benz/port.c index c73cabd5..5eed06cc 100644 --- a/extlib/benz/port.c +++ b/extlib/benz/port.c @@ -188,6 +188,9 @@ pic_get_output_string(pic_state *pic, struct pic_port *port) void pic_close_port(pic_state *pic, struct pic_port *port) { + if ((port->flags & PIC_PORT_OPEN) == 0) { + return; + } if (xfclose(port->file) == EOF) { pic_errorf(pic, "close-port: failure"); }