From: arton Date: 2007-08-23T04:37:30+09:00 Subject: [ruby-dev:31612] Re: test/win32ole artonです。 えーと、 > > test_progid(TestWIN32OLE_TYPE): > >  此処で止まります.デバッガ(VC)は win32ole.c の 2019 行目の > atof() で止まってる,みたいなことを言ってるんですが. ということなので、別のところでスタックを壊して、なんかおかしくなっている (test_on_eventも、test_progidと同じく、その影響)のではないでしょうか。 あと、この問題とは関係なさそうですが、1.8.6のソースを見て気付いたのは、 reg_get_val(hkey, subkey) HKEY hkey; const char *subkey; { char buf[BUFSIZ]; LONG size_buf = sizeof(buf); LONG err = RegQueryValue(hkey, subkey, buf, &size_buf); if (err == ERROR_SUCCESS) { return rb_str_new2(buf); } return Qnil; } はまずそうです。 というのは、RegQueryValueのAPI説明を丸々引用しますが、 If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, the string may not have been stored with the proper null-terminating characters. For example, if the string data is 12 characters and the buffer is larger than that, the function will add the null character and the size of the data returned is 13*sizeof(TCHAR) bytes. However, if the buffer is 12*sizeof(TCHAR) bytes, the data is stored successfully but does not include a terminating null. で、文字列長がぴったりBUFSIZの場合、終端nullを設定せずに、ERROR_SUCCESS が返るとなっています。その一方で、nullをコピーした場合には、&size_bufに はnullの分も入るので、return rb_str_new(buf, size_buf); とするわけにも いかないですね。 char buf[BUFSIZ + 1]; buf[BUFSIZ] = 0; としておいて、rb_str_new2(buf); かな。 -- arton -------------------------------------- Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar http://pr.mail.yahoo.co.jp/toolbar/