Project

General

Profile

Actions

Bug #6146

closed

three possible bugs by nobu

Added by mame (Yusuke Endoh) about 12 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
ruby -v:
2012-03-25
Backport:
[ruby-dev:45363]

Description

なかださん

なかださんの変更が関わってそうな箇所で Coverity Scan が教えて
くれたことを 3 つほど送ります。

1 つめ。file.c について、r34372 の変更で

3566 end = name + *alllen;

という *alllen のデリファレンスがされるようになりましたが、その
あとに

3615 if (alllen)
3616 *alllen = n;

とあるように、alllen は NULL である可能性が考慮されていたよう
です。
変更の意図はよくわかっていませんが、strlen(name) とかにしなくて
大丈夫でしょうか。

2 つめ。parse.y の intern_str で

10016 if (!--mb) enc = rb_ascii8bit_encoding();

10053 enc = rb_enc_get(rb_id2str(id));

という 2 行がありますが、どちらももそのあと enc が使われません。
紆余曲折で残った残骸っぽいですが、単に消しちゃえばいいのか確認
して頂けますでしょうか。

3 つめ。util.c の ruby_strtod で

1979 if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
1980 while (*s == '0') s++;
1981 if ((s1 = strchr(hexdigit, *s)) != NULL) {

で、1979 行目の s1 = strchr(hexdigit, *s) の代入結果が使われる
ことがありません。その後の 1991 行目のあたりも同様です。
これも紆余曲折で残った感じですが、これは消しちゃえば大丈夫ですかね?

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0