<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/ext/psych/psych_emitter.c, branch v4.0.3</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/psych] remove vim settings</title>
<updated>2025-01-15T20:11:51+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2025-01-15T17:21:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cd0abd696f9e5f5abff43f6c2aaa2ea5a68eb147'/>
<id>cd0abd696f9e5f5abff43f6c2aaa2ea5a68eb147</id>
<content type='text'>
https://github.com/ruby/psych/commit/2f46abf4e1
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/psych/commit/2f46abf4e1
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/psych] Do not depend on the evaluation order of C arguments</title>
<updated>2024-12-04T01:35:29+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2024-11-29T04:33:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a0eb541e52f43bfb3a889b9a6a69f6f37d5b79a0'/>
<id>a0eb541e52f43bfb3a889b9a6a69f6f37d5b79a0</id>
<content type='text'>
The evaluation order of C arguments is unspecified.
`RSTRING_LEN(value)` would fail if the conversion to a String by
`StringValuePtr(value)` is not done yet.

Coverity Scan found this issue.

https://github.com/ruby/psych/commit/d1e6bf323a
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The evaluation order of C arguments is unspecified.
`RSTRING_LEN(value)` would fail if the conversion to a String by
`StringValuePtr(value)` is not done yet.

Coverity Scan found this issue.

https://github.com/ruby/psych/commit/d1e6bf323a
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/psych] Guard from memory leak in Psych::Emitter#start_document</title>
<updated>2024-08-09T20:28:53+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-08-09T20:17:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7b7dde37f546b74f1dd15e482235fec139b80b70'/>
<id>7b7dde37f546b74f1dd15e482235fec139b80b70</id>
<content type='text'>
When an exception is raised, it can leak memory in `head`. There are two
places that can leak memory:

1. `Check_Type(tuple, T_ARRAY)` can leak memory if `tuple` is not an
   array.
2. `StringValue(name)` and `StringValue(value)` if they are not strings
   and the call to `to_str` does not return a string.

This commit fixes these memory leaks by wrapping the code around a
rb_ensure so that the memory is freed in all cases.

The following code demonstrates the memory leak:

    emitter = Psych::Emitter.new(StringIO.new)
    nil_to_string_tags = [[nil, "tag:TALOS"]] + ([1] * 1000)
    expected_array_tags = [1] * 1000

    10.times do
      1_000.times do
        # Raises `no implicit conversion of nil into String`
        emitter.start_document([], nil_to_string_tags, 0)
      rescue TypeError
      end

      1_000.times do
        # Raises `wrong argument type Integer (expected Array)`
        emitter.start_document([], expected_array_tags, 0)
      rescue TypeError
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    47248
    79728
    111968
    144224
    176480
    208896
    241104
    273280
    305472
    337664

After:

    14832
    15088
    15344
    15344
    15360
    15632
    15632
    15632
    15648
    15648

https://github.com/ruby/psych/commit/053af73818
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When an exception is raised, it can leak memory in `head`. There are two
places that can leak memory:

1. `Check_Type(tuple, T_ARRAY)` can leak memory if `tuple` is not an
   array.
2. `StringValue(name)` and `StringValue(value)` if they are not strings
   and the call to `to_str` does not return a string.

This commit fixes these memory leaks by wrapping the code around a
rb_ensure so that the memory is freed in all cases.

The following code demonstrates the memory leak:

    emitter = Psych::Emitter.new(StringIO.new)
    nil_to_string_tags = [[nil, "tag:TALOS"]] + ([1] * 1000)
    expected_array_tags = [1] * 1000

    10.times do
      1_000.times do
        # Raises `no implicit conversion of nil into String`
        emitter.start_document([], nil_to_string_tags, 0)
      rescue TypeError
      end

      1_000.times do
        # Raises `wrong argument type Integer (expected Array)`
        emitter.start_document([], expected_array_tags, 0)
      rescue TypeError
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    47248
    79728
    111968
    144224
    176480
    208896
    241104
    273280
    305472
    337664

After:

    14832
    15088
    15344
    15344
    15360
    15632
    15632
    15632
    15648
    15648

https://github.com/ruby/psych/commit/053af73818
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/psych] Convert missed tabs to spaces in C files</title>
<updated>2024-08-09T19:35:28+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-08-09T19:15:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=712ac99e4d0384a941c80a9f48f62943ba7d97c0'/>
<id>712ac99e4d0384a941c80a9f48f62943ba7d97c0</id>
<content type='text'>
https://github.com/ruby/psych/commit/74a6b4d226
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/psych/commit/74a6b4d226
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/psych] Convert tabs to spaces in C files</title>
<updated>2024-08-09T18:29:46+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-08-09T18:26:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e63a2115f64433b21cb5dd67c5bf8b30f87ef293'/>
<id>e63a2115f64433b21cb5dd67c5bf8b30f87ef293</id>
<content type='text'>
https://github.com/ruby/psych/commit/e7d64c9848
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/psych/commit/e7d64c9848
</pre>
</div>
</content>
</entry>
<entry>
<title>no ID cache in Init functions</title>
<updated>2018-02-16T08:39:48+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-02-16T08:39:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c8094ff154065f243292a09dce5d4c8d90f8309a'/>
<id>c8094ff154065f243292a09dce5d4c8d90f8309a</id>
<content type='text'>
Init functions are called only once, cache is useless.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Init functions are called only once, cache is useless.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>null byte at Psych::Emitter.</title>
<updated>2017-10-31T07:24:29+00:00</updated>
<author>
<name>hsbt</name>
<email>hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2017-10-31T07:24:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=865decb508e89960382fc41d239be3e42545b68a'/>
<id>865decb508e89960382fc41d239be3e42545b68a</id>
<content type='text'>
  Check null byte. Patched by tommy (Masahiro Tomita).
  [Bug #13993][ruby-dev:50285]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
  Check null byte. Patched by tommy (Masahiro Tomita).
  [Bug #13993][ruby-dev:50285]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>ext: check if null byte is contained</title>
<updated>2017-09-30T08:35:23+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2017-09-30T08:35:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1852b4a8660ee8e71997f81cee4903c6eb23f306'/>
<id>1852b4a8660ee8e71997f81cee4903c6eb23f306</id>
<content type='text'>
[ruby-dev:50267] [Bug #13953]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ruby-dev:50267] [Bug #13953]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>Update psych-2.2.1</title>
<updated>2016-11-30T13:55:02+00:00</updated>
<author>
<name>hsbt</name>
<email>hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2016-11-30T13:55:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=48e251df47c6f00adbd48a23c5fe58a1b406c060'/>
<id>48e251df47c6f00adbd48a23c5fe58a1b406c060</id>
<content type='text'>
  It fixed segmentation fault related with GC.
  https://github.com/ruby/psych/pull/296

  and removed deprecated code of Ruby 1.8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
  It fixed segmentation fault related with GC.
  https://github.com/ruby/psych/pull/296

  and removed deprecated code of Ruby 1.8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>psych_emitter.c: check tags range</title>
<updated>2015-12-13T09:28:51+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2015-12-13T09:28:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=db48c307944a9a18877236bdf9e9b778875f38ed'/>
<id>db48c307944a9a18877236bdf9e9b778875f38ed</id>
<content type='text'>
* ext/psych/psych_emitter.c (start_document): should not exceed
  tags array range.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* ext/psych/psych_emitter.c (start_document): should not exceed
  tags array range.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
</feed>
