Ruby1.9.1: やっぱりfcloseで落ちてるっぽい

VC 9.0だとだめなのかな?

#include <stdio.h>
#include "ruby.h"

static VALUE myfunc(VALUE self) {
  FILE *f;
  char buf[256];

  f = fopen("C:/foo.txt", "r+b");
  fgets(buf, 256, f);
  printf("%s\n", buf);

  return Qnil;

void Init_ruby19ext() {
  VALUE m;

  m = rb_define_module("Ruby19Ext");
  rb_define_module_function(m, "myfunc", myfunc, 0);

London bridge is falling down,

test.rb:3: [BUG] Segmentation fault
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32]

-- control frame ----------
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :myfunc
c:0003 p:0028 s:0007 b:0006 l:001af4 d:002044 EVAL test.rb:3
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001af4 d:001af4 TOP

-- Ruby level backtrace information-----------------------------------------
test.rb:3:in `myfunc'
test.rb:3:in `

You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details:

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
続行するには何かキーを押してください . . .