summary refs log tree commit
path: root/ext/json/ext/generator/generator.h
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-08-09 01:29:43 +0000
committerEric Wong <normalperson@yhbt.net>2011-08-09 03:38:59 +0000
commit8a82bffe927e8928e304b9610a75ea07b0c4a798 (patch)
tree6dbdaedbe53418d271235bbb4778b44de4484224 /ext/json/ext/generator/generator.h
parentf7f78896607b6f6226cdee4ae76de922d4583d32 (diff)
downloadruby-json-8a82bffe927e8928e304b9610a75ea07b0c4a798.tar.gz
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.
Diffstat (limited to 'ext/json/ext/generator/generator.h')
-rw-r--r--ext/json/ext/generator/generator.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/ext/json/ext/generator/generator.h b/ext/json/ext/generator/generator.h
index ee496fe..2a83149 100644
--- a/ext/json/ext/generator/generator.h
+++ b/ext/json/ext/generator/generator.h
@@ -45,8 +45,6 @@
 #define RSTRING_LEN(string) RSTRING(string)->len
 #endif
 
-#define RSTRING_PAIR(string) RSTRING_PTR(string), RSTRING_LEN(string)
-
 /* fbuffer implementation */
 
 typedef struct FBufferStruct {