ox 2.14.29 → 2.14.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ebfb30efd11a67a36973ca7fd8ada6eb2d193a0667882ccb78498cdb1362f32
4
- data.tar.gz: a1a41cceb0750adc25b6ee9dff8d7b4c2921e6335ba49e1a2daac3de39f98d16
3
+ metadata.gz: 3cc57e4626ab0b4e7a04bf5143c7f82830a3a901e2dd1266f4f8d3a269a30252
4
+ data.tar.gz: d3dfce324cb136e623faab1cf24e9304adadea01fa4aebbf11680cfdc6662a3c
5
5
  SHA512:
6
- metadata.gz: dfe7978d1f1164cdd391229803e960f929db444021ede9397e689624721b59aec4e92cbee41805d1ddf1272d04526d795a739708e386463c23240431cafd9f1b
7
- data.tar.gz: 119ca72c836197ef6d8dcd8c259b1e198563c3b94f5aac6baec45b54db3e8dfc5aa84d763d2044e8ed2173d9451806aa9a9b3a925bc95ed5c6ffffbdcc5e8cf7
6
+ metadata.gz: d318fb77496faa6993b5e70357c582ef015a051a7476f257fcfbb747e1b892446a7d5bcef8a7b082aaea484b60b56866aa999feb166ef3e8e029f5990cea959d
7
+ data.tar.gz: 540a460ad876d0b18493298d175f91c660e726a1a11a3c4a2a99ff0f081344282788f073d7bb4936b33a86d005be0932455887a907d04d61f4f333ff2261ae31
data/CHANGELOG.md CHANGED
@@ -2,6 +2,42 @@
2
2
 
3
3
  All changes to the Ox gem are documented here. Releases follow semantic versioning.
4
4
 
5
+ ## [2.14.30] - 2026-11-25
6
+
7
+ ### Added
8
+
9
+ - Speed up Ox.sax_parse by not rescanning the String on each refill. See PR #472.
10
+ - Speed up Ox.load in hash mode by keeping the marked arrays in a table. See PR #473.
11
+ - Speed up hash_no_attrs mode by interning element names directly. See PR #474.
12
+ - Speed up hash mode by interning element names directly. See PR #475.
13
+ - Added Ruby 4.0 and ARM64 runners to the CI test matrix. See PR #492.
14
+
15
+ ### Changed
16
+
17
+ - Skip the Ruby 2.7, 3.0 and 3.1 CI jobs on Ubuntu. See PR #477.
18
+
19
+ ### Fixed
20
+
21
+ - Fix an exception from the SAX input IO coming back as a TypeError. See PR #476.
22
+ - Fix slow parsing of names built to collide in the name cache. See PR #478.
23
+ - Fix object mode dumps of raised exceptions and Range subclasses. See PR #479.
24
+ - Fix out-of-bounds read in structname2obj on a trailing colon. See PR #480.
25
+ - Fix signed overflow reading long digit strings in as_i, `<i>` and `<t>`. See PR #481.
26
+ - Fix use-after-free of element names deeper than 32 in ox_sax_parse. See PR #482.
27
+ - Fix the circular reference table not being marked in mark_pi_cb. See PR #483.
28
+ - Fix a leak of the document copy in Ox.load when the parse raises. See PR #484.
29
+ - Fix use-after-free of the SAX drive through a kept Ox::Sax::Value. See PR #485.
30
+ - Fix stack buffer overflow in add_element :trace output. See PR #486.
31
+ - Fix a character reference to NUL cutting off the rest of the value. See PR #487.
32
+ - Fix read_element over-read on a tolerant unquoted attribute value. See PR #488.
33
+ - Fix a leak of the name of an empty element in Ox::Builder pop. See PR #489.
34
+ - Fix Ox::Sax::Value#as_s decoding the value again on each call. See PR #490.
35
+ - Fix Time conversion on 32-bit time_t builds. See PR #493.
36
+ - Fix use-after-free of a popped element in hash mode end_element. See PR #494.
37
+ - Fix out-of-bounds read in form_attr interning the stack buffer. See PR #495.
38
+ - Fix read_element over-read on a tolerant end tag cut off before its '>'. See PR #496.
39
+ - Fix read_instruction over-read on an instruction ending in '?' with no '>'. See PR #497.
40
+
5
41
  ## [2.14.29] - 2026-07-08
6
42
 
7
43
  ### Added
data/ext/ox/builder.c CHANGED
@@ -403,15 +403,17 @@ static void pop(Builder b) {
403
403
  // and the ">".
404
404
  b->col += 3;
405
405
  b->pos += 3;
406
- if (e->buf != e->name) {
407
- free(e->name);
408
- e->name = 0;
409
- }
410
406
  } else {
411
407
  buf_append_string(&b->buf, "/>", 2);
412
408
  b->col += 2;
413
409
  b->pos += 2;
414
410
  }
411
+ // A name too long for the inline buffer was strdup'd, and an element closed
412
+ // with "/>" owns that copy just as much as one with children.
413
+ if (e->buf != e->name) {
414
+ free(e->name);
415
+ e->name = 0;
416
+ }
415
417
  }
416
418
 
417
419
  static void bclose(Builder b) {
data/ext/ox/cache.c CHANGED
@@ -24,24 +24,34 @@
24
24
  #define CACHE_UNLOCK(c) rb_mutex_unlock((c)->mutex)
25
25
  #endif
26
26
 
27
- // almost the Murmur hash algorithm
28
- #define M 0x5bd1e995
29
-
30
- // Mixed into the initial state of hash_calc(). Element and attribute names come
31
- // straight from the document, so without a per process seed the bucket every
32
- // name lands in can be precomputed offline. Written once by ox_hash_seed_init()
33
- // during Init_ox and only read afterwards, so the caches stay Ractor safe.
34
- static uint64_t hash_seed = 0;
27
+ #define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
28
+ #define SIPROUND \
29
+ do { \
30
+ v0 += v1; \
31
+ v1 = ROTL(v1, 13); \
32
+ v1 ^= v0; \
33
+ v0 = ROTL(v0, 32); \
34
+ v2 += v3; \
35
+ v3 = ROTL(v3, 16); \
36
+ v3 ^= v2; \
37
+ v0 += v3; \
38
+ v3 = ROTL(v3, 21); \
39
+ v3 ^= v0; \
40
+ v2 += v1; \
41
+ v1 = ROTL(v1, 17); \
42
+ v1 ^= v2; \
43
+ v2 = ROTL(v2, 32); \
44
+ } while (0)
45
+
46
+ static uint64_t hash_key[2];
35
47
 
36
48
  void ox_hash_seed_init(void) {
37
- #ifdef HAVE_RB_HASH_START
38
- // Folds in the random seed Ruby uses to defend Hash against the same attack.
39
- hash_seed = (uint64_t)rb_hash_start(0);
40
- #else
41
- // String#hash is per process randomized too. It can be negative, so take it
42
- // as signed and reinterpret rather than letting NUM2ULL reject it.
43
- hash_seed = (uint64_t)(int64_t)NUM2LL(rb_funcall(rb_str_new_literal("ox"), rb_intern("hash"), 0));
44
- #endif
49
+ VALUE seed = rb_funcall(rb_cRandom, rb_intern("new_seed"), 0);
50
+ VALUE mask = ULL2NUM(UINT64_MAX);
51
+
52
+ hash_key[0] = NUM2ULL(rb_funcall(seed, rb_intern("&"), 1, mask)) ^ (uint64_t)rb_memhash("ox0", 3);
53
+ hash_key[1] = NUM2ULL(rb_funcall(rb_funcall(seed, rb_intern(">>"), 1, INT2FIX(64)), rb_intern("&"), 1, mask)) ^
54
+ (uint64_t)rb_memhash("ox1", 3);
45
55
  }
46
56
 
47
57
  typedef struct _slot {
@@ -83,37 +93,36 @@ const rb_data_type_t ox_cache_type = {
83
93
  };
84
94
 
85
95
  static uint64_t hash_calc(const uint8_t *key, size_t len) {
86
- const uint8_t *end = key + len;
87
- const uint8_t *endless = key + (len & 0xFFFFFFFC);
88
- uint64_t h = (uint64_t)len ^ hash_seed;
89
- uint64_t k;
90
-
91
- while (key < endless) {
92
- k = (uint64_t)*key++;
93
- k |= (uint64_t)*key++ << 8;
94
- k |= (uint64_t)*key++ << 16;
95
- k |= (uint64_t)*key++ << 24;
96
-
97
- k *= M;
98
- k ^= k >> 24;
99
- h *= M;
100
- h ^= k * M;
101
- }
102
- if (1 < end - key) {
103
- uint16_t k16 = (uint16_t)*key++;
104
-
105
- k16 |= (uint16_t)*key++ << 8;
106
- h ^= k16 << 8;
96
+ const uint8_t *end = key + (len & ~(size_t)7);
97
+ uint64_t v0 = 0x736f6d6570736575ULL ^ hash_key[0];
98
+ uint64_t v1 = 0x646f72616e646f6dULL ^ hash_key[1];
99
+ uint64_t v2 = 0x6c7967656e657261ULL ^ hash_key[0];
100
+ uint64_t v3 = 0x7465646279746573ULL ^ hash_key[1];
101
+ uint64_t b = (uint64_t)len << 56;
102
+ uint64_t m;
103
+ size_t i;
104
+
105
+ for (; key < end; key += 8) {
106
+ m = 0;
107
+ for (i = 0; i < 8; i++) {
108
+ m |= (uint64_t)key[i] << (8 * i);
109
+ }
110
+ v3 ^= m;
111
+ SIPROUND;
112
+ v0 ^= m;
107
113
  }
108
- if (key < end) {
109
- h ^= *key;
114
+ for (i = 0; i < (len & 7); i++) {
115
+ b |= (uint64_t)key[i] << (8 * i);
110
116
  }
111
- h *= M;
112
- h ^= h >> 13;
113
- h *= M;
114
- h ^= h >> 15;
115
-
116
- return h;
117
+ v3 ^= b;
118
+ SIPROUND;
119
+ v0 ^= b;
120
+ v2 ^= 0xff;
121
+ SIPROUND;
122
+ SIPROUND;
123
+ SIPROUND;
124
+
125
+ return v0 ^ v1 ^ v2 ^ v3;
117
126
  }
118
127
 
119
128
  static void rehash(Cache c) {
data/ext/ox/dump.c CHANGED
@@ -477,16 +477,18 @@ inline static void dump_num(Out out, VALUE obj) {
477
477
  }
478
478
 
479
479
  static void dump_time_thin(Out out, VALUE obj) {
480
- char buf[64];
481
- char *b = buf + sizeof(buf) - 1;
482
- struct timespec ts = rb_time_timespec(obj);
483
- time_t sec = ts.tv_sec;
484
- long nsec = ts.tv_nsec;
485
- char *dot = b - 10;
486
- long size;
487
- bool neg = 0 > sec;
488
-
489
- // tv_nsec is never negative, so a time before the epoch is a negative
480
+ char buf[64];
481
+ char *b = buf + sizeof(buf) - 1;
482
+ ox_time_t sec;
483
+ long nsec;
484
+ char *dot = b - 10;
485
+ long size;
486
+ bool neg;
487
+
488
+ ox_time_split(obj, &sec, &nsec);
489
+ neg = 0 > sec;
490
+
491
+ // nsec is never negative, so a time before the epoch is a negative
490
492
  // second count carrying a positive fraction. Writing those two out as they
491
493
  // are would read as -1.5 for what is really -0.5, so move the fraction over
492
494
  // and write the magnitude with a sign in front of it.
@@ -503,7 +505,7 @@ static void dump_time_thin(Out out, VALUE obj) {
503
505
  *b-- = '0';
504
506
  } else if (neg) {
505
507
  // sec is left negative instead of negated so that the most negative
506
- // time_t does not overflow. C truncates the quotient toward zero, so
508
+ // ox_time_t does not overflow. C truncates the quotient toward zero, so
507
509
  // the remainder carries the sign with it.
508
510
  for (; 0 != sec; b--, sec /= 10) {
509
511
  *b = (char)('0' - sec % 10);
@@ -552,17 +554,17 @@ static void dump_date(Out out, VALUE obj) {
552
554
  }
553
555
 
554
556
  static void dump_time_xsd(Out out, VALUE obj) {
555
- struct timespec ts = rb_time_timespec(obj);
556
- time_t sec = ts.tv_sec;
557
- long nsec = ts.tv_nsec;
558
- long offset = NUM2LONG(rb_funcall2(obj, ox_utc_offset_id, 0, 0));
559
- int tzhour, tzmin;
560
- char tzsign = '+';
561
- long long year;
562
- int mon, day, hour, min, tsec;
563
- char buf[64];
564
- int cnt;
565
-
557
+ ox_time_t sec;
558
+ long nsec;
559
+ long offset = NUM2LONG(rb_funcall2(obj, ox_utc_offset_id, 0, 0));
560
+ int tzhour, tzmin;
561
+ char tzsign = '+';
562
+ long long year;
563
+ int mon, day, hour, min, tsec;
564
+ char buf[64];
565
+ int cnt;
566
+
567
+ ox_time_split(obj, &sec, &nsec);
566
568
  /* 2010-07-09T10:47:45.895826+09:00 */
567
569
  // The offset comes from the Time rather than from localtime(), which has no
568
570
  // tm_gmtoff in the Microsoft CRT and so wrote +00:00 next to a local wall
@@ -586,7 +588,7 @@ static void dump_time_xsd(Out out, VALUE obj) {
586
588
  /* TBD replace with more efficient printer */
587
589
  // A year outside four digits is longer than the sample above, so reserve
588
590
  // what was actually formatted instead of a fixed 33. buf can not overflow:
589
- // the largest time_t puts the year at 12 digits, and the rest of the format
591
+ // the largest ox_time_t puts the year at 12 digits, and the rest of the format
590
592
  // is a fixed 28 characters.
591
593
  cnt = snprintf(buf,
592
594
  sizeof(buf),
@@ -900,6 +902,14 @@ static void dump_obj(ID aid, VALUE obj, int depth, Out out) {
900
902
  VALUE v = RSTRUCT_GET(obj, (int)(i));
901
903
  dump_obj(rb_intern(ulong2str(i, num_buf + sizeof(num_buf) - 1)), v, d2, out);
902
904
  }
905
+ if (2 == cnt && Qtrue == rb_obj_is_kind_of(obj, rb_cRange)) {
906
+ VALUE beg;
907
+ VALUE end;
908
+ int excl;
909
+
910
+ rb_range_values(obj, &beg, &end, &excl);
911
+ dump_obj(rb_intern(ulong2str(i, num_buf + sizeof(num_buf) - 1)), excl ? Qtrue : Qfalse, d2, out);
912
+ }
903
913
  out->w_end(out, &e);
904
914
  }
905
915
  #else
@@ -1032,6 +1042,12 @@ static int dump_var(ID key, VALUE value, VALUE ov) {
1032
1042
  * time.
1033
1043
  */
1034
1044
  value = rb_funcall(out->obj, ox_message_id, 0);
1045
+ } else if (T_DATA == rb_type(value) && key == rb_intern("bt")) {
1046
+ VALUE m = rb_funcall(rb_eException, rb_intern("instance_method"), 1, ID2SYM(rb_intern("backtrace")));
1047
+
1048
+ value = rb_funcall(m, rb_intern("bind_call"), 1, out->obj);
1049
+ } else if (key == rb_intern("bt_locations")) {
1050
+ return ST_CONTINUE;
1035
1051
  }
1036
1052
  dump_obj(key, value, out->depth, out);
1037
1053
 
data/ext/ox/extconf.rb CHANGED
@@ -46,9 +46,6 @@ have_func('rb_ext_ractor_safe', 'ruby.h')
46
46
  have_func('pthread_mutex_init')
47
47
  have_func('rb_enc_interned_str')
48
48
  have_func('index')
49
- # Seeds the name cache hash. Not on every implementation, so cache.c falls back
50
- # to String#hash, which is per process randomized everywhere it matters.
51
- have_func('rb_hash_start', 'ruby.h')
52
49
 
53
50
  have_header('ruby/st.h')
54
51
  have_header('sys/uio.h')
data/ext/ox/hash_load.c CHANGED
@@ -13,8 +13,6 @@
13
13
  #include "ox.h"
14
14
  #include "ruby.h"
15
15
 
16
- #define MARK_INC 256
17
-
18
16
  // The approach taken for the hash and has_no_attrs parsing is to push just
19
17
  // the key on to the stack and then decide what to do on the way up/out.
20
18
 
@@ -27,45 +25,26 @@ static VALUE create_top(PInfo pi) {
27
25
  return top;
28
26
  }
29
27
 
28
+ // Only membership is ever asked of these. As a list they were walked end to
29
+ // end on every close, which is quadratic in the number of repeated elements
30
+ // that carry attributes, since each of those adds a mark and only one is
31
+ // ever taken back.
30
32
  static void mark_value(PInfo pi, VALUE val) {
31
33
  if (NULL == pi->marked) {
32
- pi->marked = ALLOC_N(VALUE, MARK_INC);
33
- pi->mark_size = MARK_INC;
34
- } else if (pi->mark_size <= pi->mark_cnt) {
35
- pi->mark_size += MARK_INC;
36
- REALLOC_N(pi->marked, VALUE, pi->mark_size);
34
+ pi->marked = st_init_numtable();
37
35
  }
38
- pi->marked[pi->mark_cnt] = val;
39
- pi->mark_cnt++;
36
+ st_insert(pi->marked, (st_data_t)val, (st_data_t)1);
40
37
  }
41
38
 
42
39
  static bool marked(PInfo pi, VALUE val) {
43
- if (NULL != pi->marked) {
44
- VALUE *vp = pi->marked + pi->mark_cnt - 1;
45
-
46
- for (; pi->marked <= vp; vp--) {
47
- if (val == *vp) {
48
- return true;
49
- }
50
- }
51
- }
52
- return false;
40
+ return NULL != pi->marked && 0 != st_lookup(pi->marked, (st_data_t)val, NULL);
53
41
  }
54
42
 
55
43
  static void unmark(PInfo pi, VALUE val) {
56
44
  if (NULL != pi->marked) {
57
- VALUE *vp = pi->marked + pi->mark_cnt - 1;
58
- int i;
59
-
60
- for (i = 0; pi->marked <= vp; vp--, i++) {
61
- if (val == *vp) {
62
- for (; 0 < i; i--, vp++) {
63
- *vp = *(vp + 1);
64
- }
65
- pi->mark_cnt--;
66
- break;
67
- }
68
- }
45
+ st_data_t key = (st_data_t)val;
46
+
47
+ st_delete(pi->marked, &key, NULL);
69
48
  }
70
49
  }
71
50
 
@@ -109,10 +88,10 @@ static void add_cdata(PInfo pi, const char *text, size_t len) {
109
88
  }
110
89
 
111
90
  static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
112
- VALUE s = rb_str_new2(ename);
113
- if (0 != pi->options->rb_enc) {
114
- rb_enc_associate(s, pi->options->rb_enc);
115
- }
91
+ // Keep the name's encoding without allocating a temporary String. Intern
92
+ // after the attributes as before, including any key modifier callbacks.
93
+ rb_encoding *enc = NULL == pi->options->rb_enc ? rb_ascii8bit_encoding() : pi->options->rb_enc;
94
+
116
95
  if (helper_stack_empty(&pi->helpers)) {
117
96
  create_top(pi);
118
97
  }
@@ -141,21 +120,24 @@ static void add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren
141
120
  a = rb_ary_new();
142
121
  rb_ary_push(a, h);
143
122
  mark_value(pi, a);
144
- helper_stack_push(&pi->helpers, rb_intern_str(s), a, ArrayCode);
123
+ helper_stack_push(&pi->helpers, rb_intern3(ename, strlen(ename), enc), a, ArrayCode);
145
124
  } else {
146
- helper_stack_push(&pi->helpers, rb_intern_str(s), Qnil, NoCode);
125
+ helper_stack_push(&pi->helpers, rb_intern3(ename, strlen(ename), enc), Qnil, NoCode);
147
126
  }
148
127
  }
149
128
 
150
129
  static void add_element_no_attrs(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
151
- VALUE s = rb_str_new2(ename);
152
- if (0 != pi->options->rb_enc) {
153
- rb_enc_associate(s, pi->options->rb_enc);
154
- }
130
+ rb_encoding *enc = pi->options->rb_enc;
131
+
155
132
  if (helper_stack_empty(&pi->helpers)) {
156
133
  create_top(pi);
157
134
  }
158
- helper_stack_push(&pi->helpers, rb_intern_str(s), Qnil, NoCode);
135
+ // Intern the name without a temporary String, preserving rb_str_new2's
136
+ // binary encoding when the parser has no encoding set.
137
+ helper_stack_push(&pi->helpers,
138
+ rb_intern3(ename, strlen(ename), NULL == enc ? rb_ascii8bit_encoding() : enc),
139
+ Qnil,
140
+ NoCode);
159
141
  }
160
142
 
161
143
  static int umark_hash_cb(VALUE key, VALUE value, VALUE x) {
@@ -171,10 +153,11 @@ static void end_element_core(PInfo pi, const char *ename, bool check_marked) {
171
153
  volatile VALUE found = Qundef;
172
154
  volatile VALUE key;
173
155
  volatile VALUE a;
156
+ // The popped slot is past the tail mark_pi_cb walks, and on the heap once
157
+ // the stack outgrows its base, so hold the value where the GC can see it
158
+ // before anything below allocates.
159
+ volatile VALUE obj = (NoCode == e->type) ? Qnil : e->obj;
174
160
 
175
- if (NoCode == e->type) {
176
- e->obj = Qnil;
177
- }
178
161
  if (Qnil != pi->options->element_key_mod) {
179
162
  key = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, rb_id2str(e->var));
180
163
  } else if (Yes == pi->options->sym_keys) {
@@ -205,28 +188,28 @@ static void end_element_core(PInfo pi, const char *ename, bool check_marked) {
205
188
  break;
206
189
  }
207
190
  if (Qundef == found) {
208
- rb_hash_aset(pobj, key, e->obj);
191
+ rb_hash_aset(pobj, key, obj);
209
192
  } else if (RUBY_T_ARRAY == rb_type(found)) {
210
193
  if (check_marked && marked(pi, found)) {
211
194
  unmark(pi, found);
212
195
  a = rb_ary_new();
213
196
  rb_ary_push(a, found);
214
- rb_ary_push(a, e->obj);
197
+ rb_ary_push(a, obj);
215
198
  rb_hash_aset(pobj, key, a);
216
199
  } else {
217
- rb_ary_push(found, e->obj);
200
+ rb_ary_push(found, obj);
218
201
  }
219
202
  } else { // something there other than an array
220
- if (check_marked && marked(pi, e->obj)) {
221
- unmark(pi, e->obj);
203
+ if (check_marked && marked(pi, obj)) {
204
+ unmark(pi, obj);
222
205
  }
223
206
  a = rb_ary_new();
224
207
  rb_ary_push(a, found);
225
- rb_ary_push(a, e->obj);
208
+ rb_ary_push(a, obj);
226
209
  rb_hash_aset(pobj, key, a);
227
210
  }
228
- if (check_marked && NULL != pi->marked && RUBY_T_HASH == rb_type(e->obj)) {
229
- rb_hash_foreach(e->obj, umark_hash_cb, (VALUE)pi);
211
+ if (check_marked && NULL != pi->marked && RUBY_T_HASH == rb_type(obj)) {
212
+ rb_hash_foreach(obj, umark_hash_cb, (VALUE)pi);
230
213
  }
231
214
  }
232
215
 
@@ -239,12 +222,12 @@ static void end_element_no_attrs(PInfo pi, const char *ename) {
239
222
  }
240
223
 
241
224
  static void finish(PInfo pi) {
242
- // Called once per yielded entity and once after the loop, so the pointer
243
- // and the count have to go with the block.
244
- xfree(pi->marked);
245
- pi->marked = NULL;
246
- pi->mark_size = 0;
247
- pi->mark_cnt = 0;
225
+ // Called once per yielded entity and once after the loop, so the table has
226
+ // to go with the block.
227
+ if (NULL != pi->marked) {
228
+ st_free_table(pi->marked);
229
+ pi->marked = NULL;
230
+ }
248
231
  }
249
232
 
250
233
  static void set_encoding_from_instruct(PInfo pi, Attr attrs) {
data/ext/ox/intern.c CHANGED
@@ -47,7 +47,7 @@ static VALUE form_attr(const char *str, size_t len) {
47
47
  memcpy(b + 1, str, len);
48
48
  b[len + 1] = '\0';
49
49
  }
50
- id = rb_intern3(buf, len + 1, rb_utf8_encoding());
50
+ id = rb_intern3(b, len + 1, rb_utf8_encoding());
51
51
  xfree(b);
52
52
  return id;
53
53
  }