Project

General

Profile

Actions

Bug #5173

closed

[PATCH] json/generator: prevent GC of temporary strings

Added by normalperson (Eric Wong) over 12 years ago. Updated over 12 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.4dev (2011-08-07 trunk 32885) [x86_64-linux]
Backport:
[ruby-core:38866]

Description

ext/json/generator/generator.c: prevent GC of temporary strings

We need to guard temporary strings from being collected while we
append to the JSON buffer (which may allocate memory). The
RSTRING_PAIR macro is dangerous since it preserves no pointer to
the original string VALUE, allowing GC to reap the object while
we're still using the (C) string pointer.

The included test case shows data corruption with large
Bignums without this fix.

If you prefer git pull: git pull git://bogomips.org/ruby json-gc-guard


Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0