[bugfix] port leaks

This commit is contained in:
Yuichi Nishiwaki 2015-06-26 23:45:56 +09:00
parent 8e90517224
commit 8b550de06a
2 changed files with 14 additions and 2 deletions

View File

@ -22,7 +22,13 @@ pic_load_cstr(pic_state *pic, const char *src)
{ {
struct pic_port *port = pic_open_input_string(pic, src); struct pic_port *port = pic_open_input_string(pic, src);
pic_load_port(pic, port); pic_try {
pic_load_port(pic, port);
}
pic_catch {
pic_close_port(pic, port);
pic_raise(pic, pic->err);
}
pic_close_port(pic, port); pic_close_port(pic, port);
} }

View File

@ -881,7 +881,13 @@ pic_read_cstr(pic_state *pic, const char *str)
struct pic_port *port = pic_open_input_string(pic, str); struct pic_port *port = pic_open_input_string(pic, str);
pic_value form; pic_value form;
form = pic_read(pic, port); pic_try {
form = pic_read(pic, port);
}
pic_catch {
pic_close_port(pic, port);
pic_raise(pic, pic->err);
}
pic_close_port(pic, port); pic_close_port(pic, port);