Skip to content

Commit

Permalink
* pack.c (PACK_ITEM_ADJUST): return nil not result array and yield
Browse files Browse the repository at this point in the history
  values if block is given.  [ruby-core:33193]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Nov 15, 2010
1 parent 0dbe6b6 commit 8b09bf2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Tue Nov 16 06:39:31 2010 Nobuyoshi Nakada <[email protected]>

* 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 <[email protected]>

* regparse.c (and_cclass, or_cclass): fix memory leak. Coverity Scan
Expand Down
2 changes: 1 addition & 1 deletion pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions test/ruby/test_pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -630,4 +630,11 @@ def test_short_string
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

0 comments on commit 8b09bf2

Please sign in to comment.