diff --git a/ChangeLog b/ChangeLog index 472f123a48..e0e6905007 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun May 13 22:46:36 2012 Tanaka Akira + + * ext/etc/etc.c (passwd_ensure): move endpwent() call from + passwd_iterate to close /etc/passwd on exception. + (group_ensure): move endgrent() call from group_iterate to close + /etc/group on exception. + Sun May 13 18:10:43 2012 Tadayoshi Funaba * ext/date/date_strftime.c: removed unused code and changed the style. diff --git a/ext/etc/etc.c b/ext/etc/etc.c index 56aab7fb7f..1c1ab813d9 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -174,6 +174,7 @@ static int passwd_blocking = 0; static VALUE passwd_ensure(void) { + endpwent(); passwd_blocking = (int)Qfalse; return Qnil; } @@ -187,7 +188,6 @@ passwd_iterate(void) while (pw = getpwent()) { rb_yield(setup_passwd(pw)); } - endpwent(); return Qnil; } @@ -412,6 +412,7 @@ static int group_blocking = 0; static VALUE group_ensure(void) { + endgrent(); group_blocking = (int)Qfalse; return Qnil; } @@ -425,7 +426,6 @@ group_iterate(void) while (pw = getgrent()) { rb_yield(setup_group(pw)); } - endgrent(); return Qnil; }