From: Koji Arai Date: 1999-03-27T23:03:36+09:00 Subject: [ruby-dev:6532] SEGV on kconv 新井です。 以下が、SEGVします。 #!/usr/local/bin/ruby require "kconv.rb" class String def toeuc! replace Kconv::toeuc(self) end end s = "\xff" p Kconv::toeuc(s).size p s.toeuc! __END__ $ ruby-1.3.1-990324 hoge.rb -1 hoge.rb:6: [BUG] Segmentation fault IOT trap/Abort (core dumped) nkf では、 $ echo -ne '\xff' | nkf -e | wc -c 0 となるので、サイズチェックだけでいいのでしょう。 パッチです。 --- ext/nkf/nkf.c.org Sat Feb 27 00:37:47 1999 +++ ext/nkf/nkf.c Sat Mar 27 22:42:47 1999 @@ -78,7 +78,7 @@ rb_nkf_kconv(obj, opt, src) } kanji_convert(NULL); - output_ctr--; + if (output_ctr > 0) output_ctr--; if (output[output_ctr] == '\0') { /* printf("([%c][%d])\n", output[output_ctr], output_ctr);