diff --git a/ChangeLog b/ChangeLog index bb6a5fbccd..2f1cf8ddfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Nov 16 06:39:31 2010 Nobuyoshi Nakada + + * pack.c (PACK_ITEM_ADJUST): return nil not result array and yield + values if block is given. [ruby-core:33193] + Tue Nov 16 00:21:20 2010 Yusuke Endoh * regparse.c (and_cclass, or_cclass): fix memory leak. Coverity Scan diff --git a/pack.c b/pack.c index 6befada66d..39a5922661 100644 --- a/pack.c +++ b/pack.c @@ -1221,7 +1221,7 @@ hex2num(char c) } while (0) #define PACK_ITEM_ADJUST() do { \ - if (tmp_len > 0) \ + if (tmp_len > 0 && !block_p) \ rb_ary_store(ary, RARRAY_LEN(ary)+tmp_len-1, Qnil); \ } while (0) diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 83b4582776..a668f7b218 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -630,4 +630,11 @@ class TestPack < Test::Unit::TestCase assert_equal([1,nil], str.unpack("#{fmt}2")) } end + + def test_short_with_block + bug4059 = '[ruby-core:33193]' + result = :ok + assert_nil("".unpack("i") {|x| result = x}, bug4059) + assert_equal(:ok, result) + end end