diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-09 05:42:06 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-09 05:42:06 +0000 |
commit | 4058446709f6907d3446787efdb305c64a2a1ef4 (patch) | |
tree | 4b16acf01b6079779eb98fe73eefb586437e0bcf /iseq.h | |
parent | 3528b6a9a972992fce1a257469afdd7af5914455 (diff) | |
download | ruby-4058446709f6907d3446787efdb305c64a2a1ef4.tar.gz |
RSTRING_PTR is not guaranteed to be VALUE-aligned (retry)
Don't abuse struct RString to hold arbitrary memory region.
Raw pointer should just suffice.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.h')
-rw-r--r-- | iseq.h | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -46,23 +46,24 @@ ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq) static inline VALUE * ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq) { - VALUE str = iseq->body->variable.original_iseq; - if (RTEST(str)) return (VALUE *)RSTRING_PTR(str); - return NULL; + return iseq->body->variable.original_iseq; } static inline void ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq) { - RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, Qnil); + void *ptr = iseq->body->variable.original_iseq; + iseq->body->variable.original_iseq = NULL; + if (ptr) { + ruby_xfree(ptr); + } } static inline VALUE * ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size) { - VALUE str = rb_str_tmp_new(size * sizeof(VALUE)); - RB_OBJ_WRITE(iseq, &iseq->body->variable.original_iseq, str); - return (VALUE *)RSTRING_PTR(str); + return iseq->body->variable.original_iseq = + ruby_xmalloc2(sizeof(VALUE), size); } #define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \ |