[Backport93 - Backport #6146][Open] three possible bugs by nobu

Issue #6146 has been reported by Yusuke E…


Backport #6146: three possible bugs by nobu

Author: Yusuke E.
Status: Open
Priority: Normal
Assignee: Nobuyoshi N.
Category:
Target version:

なかださん

なかださんの変更が関わってそうな箇所で 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 E. [email protected]

Issue #6146 has been updated by Nobuyoshi N…

Category set to core
Status changed from Open to Closed
Target version set to 2.0.0
% Done changed from 0 to 100
ruby -v set to 2012-03-25

r35033,r35034,r35035

Bug #6146: three possible bugs by nobu

Author: Yusuke E.
Status: Closed
Priority: Normal
Assignee: Nobuyoshi N.
Category: core
Target version: 2.0.0
ruby -v: 2012-03-25

なかださん

なかださんの変更が関わってそうな箇所で 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 E. [email protected]