ox 2.14.12 → 2.14.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf4c5ff67edda493ebf9fd2a29fcee1584b0310f917094dec0a57eb93632f412
4
- data.tar.gz: 7283aca3a2a2770f72696410a6691c131cfa2777562cd882f76bb0ea643c414e
3
+ metadata.gz: e05d933efc3ea58f72d9c9d9851d6dab608613f7614a09fa6b4dbed5b998b094
4
+ data.tar.gz: 9f85899f321b465fb0cb3b65e1a39d0182b9171505b04758bae30e24a4c1f76d
5
5
  SHA512:
6
- metadata.gz: e6ada04ac77531e74f5d40995d660d6e993d9c69685c586d15cbd9c896dfe6c60df879a51adecf5f5d3cb860b8bcb3fd80116a1001ae6eb5d15fbeb472be7118
7
- data.tar.gz: 4053266ff36240627decb9eefbdc30e1afcb07bf36fed7ad639d2e1cfbff5165991f59ee1fdc985259f6dc60e4394e4782df98de9c73c2e51be911f39436d595
6
+ metadata.gz: a19ec4e471fd35baba036fcdb01bc1d01820a0aac236a94d4da4cf10fde4da49a2c6cd144c1407ba42605b50c1239587bcee993aba5edb36219f65577742173b
7
+ data.tar.gz: dd1839eab2fef06690186839f81a17ed364c4713e9029960b81caf66ddc818b8892429eb60c1a0673de81ef53398946a5da89f2775078ad5fe85c4fbb2386b38
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All changes to the Ox gem are documented here. Releases follow semantic versioning.
4
4
 
5
+ ## [2.14.14] - 2023-01-26
6
+
7
+ ### Fixed
8
+
9
+ - Change free to xfree on ruby alloced memory.
10
+
11
+ ## [2.14.13] - 2023-01-16
12
+
13
+ ### Fixed
14
+
15
+ - Fixed the intern cache to handle symbol memory changes.
16
+
5
17
  ## [2.14.12] - 2022-12-27
6
18
 
7
19
  ### Fixed
data/ext/ox/hash_load.c CHANGED
@@ -35,7 +35,7 @@ mark_value(PInfo pi, VALUE val) {
35
35
  pi->mark_size = MARK_INC;
36
36
  } else if (pi->mark_size <= pi->mark_cnt) {
37
37
  pi->mark_size += MARK_INC;
38
- pi->marked = REALLOC_N(pi->marked, VALUE, pi->mark_size);
38
+ REALLOC_N(pi->marked, VALUE, pi->mark_size);
39
39
  }
40
40
  pi->marked[pi->mark_cnt] = val;
41
41
  pi->mark_cnt++;
data/ext/ox/sax.c CHANGED
@@ -762,6 +762,7 @@ CB:
762
762
  */
763
763
  static char read_element_start(SaxDrive dr) {
764
764
  const char *ename = 0;
765
+ size_t nlen;
765
766
  volatile VALUE name = Qnil;
766
767
  char c;
767
768
  int closed;
@@ -790,6 +791,7 @@ static char read_element_start(SaxDrive dr) {
790
791
  0 == strcasecmp("html", dr->buf.str)) {
791
792
  dr->options.hints = ox_hints_html();
792
793
  }
794
+ nlen = dr->buf.tail - dr->buf.str - 1;
793
795
  if (NULL != dr->options.hints) {
794
796
  hint_clear_empty(dr);
795
797
  h = ox_hint_find(dr->options.hints, dr->buf.str);
@@ -810,7 +812,7 @@ static char read_element_start(SaxDrive dr) {
810
812
  if (rb_respond_to(dr->handler, ox_abort_id)) {
811
813
  VALUE args[1];
812
814
 
813
- args[0] = str2sym(dr, dr->buf.str, dr->buf.tail - dr->buf.str - 1, NULL);
815
+ args[0] = str2sym(dr, dr->buf.str, nlen, NULL);
814
816
  rb_funcall2(dr->handler, ox_abort_id, 1, args);
815
817
  }
816
818
  dr->abort = true;
@@ -861,7 +863,7 @@ static char read_element_start(SaxDrive dr) {
861
863
  }
862
864
  }
863
865
  }
864
- name = str2sym(dr, dr->buf.str, dr->buf.tail - dr->buf.str - 1, &ename);
866
+ name = str2sym(dr, dr->buf.str, nlen, &ename);
865
867
  if (dr->has_start_element && 0 >= dr->blocked &&
866
868
  (NULL == h || ActiveOverlay == h->overlay || NestOverlay == h->overlay)) {
867
869
  VALUE args[1];
@@ -894,7 +896,7 @@ static char read_element_start(SaxDrive dr) {
894
896
  } else if (stackless) {
895
897
  end_element_cb(dr, name, pos, line, col, h);
896
898
  } else if (NULL != h && h->jump) {
897
- stack_push(&dr->stack, ename, name, h);
899
+ stack_push(&dr->stack, ename, nlen, name, h);
898
900
  if ('>' != c) {
899
901
  ox_sax_drive_error(dr, WRONG_CHAR "element not closed");
900
902
  return c;
@@ -902,7 +904,7 @@ static char read_element_start(SaxDrive dr) {
902
904
  read_jump(dr, h->name);
903
905
  return '<';
904
906
  } else {
905
- stack_push(&dr->stack, ename, name, h);
907
+ stack_push(&dr->stack, ename, nlen, name, h);
906
908
  }
907
909
  if ('>' != c) {
908
910
  ox_sax_drive_error(dr, WRONG_CHAR "element not closed");
data/ext/ox/sax_stack.h CHANGED
@@ -6,11 +6,16 @@
6
6
  #ifndef OX_SAX_STACK_H
7
7
  #define OX_SAX_STACK_H
8
8
 
9
+ #include <stdlib.h>
10
+
11
+ #include "intern.h"
9
12
  #include "sax_hint.h"
10
13
 
11
14
  #define STACK_INC 32
15
+ #define NV_BUF_MAX 64
12
16
 
13
17
  typedef struct _nv {
18
+ char name_buf[NV_BUF_MAX];
14
19
  const char *name;
15
20
  VALUE val;
16
21
  int childCnt;
@@ -44,7 +49,7 @@ stack_cleanup(NStack stack) {
44
49
  }
45
50
 
46
51
  inline static void
47
- stack_push(NStack stack, const char *name, VALUE val, Hint hint) {
52
+ stack_push(NStack stack, const char *name, size_t nlen, VALUE val, Hint hint) {
48
53
  if (stack->end <= stack->tail) {
49
54
  size_t len = stack->end - stack->head;
50
55
  size_t toff = stack->tail - stack->head;
@@ -58,7 +63,13 @@ stack_push(NStack stack, const char *name, VALUE val, Hint hint) {
58
63
  stack->tail = stack->head + toff;
59
64
  stack->end = stack->head + len + STACK_INC;
60
65
  }
61
- stack->tail->name = name;
66
+ if (NV_BUF_MAX <= nlen) {
67
+ stack->tail->name = ox_strndup(name, nlen);
68
+ } else {
69
+ strncpy(stack->tail->name_buf, name, nlen);
70
+ stack->tail->name_buf[nlen] = '\0';
71
+ stack->tail->name = stack->tail->name_buf;
72
+ }
62
73
  stack->tail->val = val;
63
74
  stack->tail->hint = hint;
64
75
  stack->tail->childCnt = 0;
@@ -77,6 +88,9 @@ inline static Nv
77
88
  stack_pop(NStack stack) {
78
89
  if (stack->head < stack->tail) {
79
90
  stack->tail--;
91
+ if (stack->tail->name != stack->tail->name_buf) {
92
+ xfree((char*)(stack->tail->name));
93
+ }
80
94
  return stack->tail;
81
95
  }
82
96
  return 0;
data/lib/ox/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '2.14.12'
4
+ VERSION = '2.14.14'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.12
4
+ version: 2.14.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-27 00:00:00.000000000 Z
11
+ date: 2023-01-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "A fast XML parser and object serializer that uses only standard C lib.\n\nOptimized
14
14
  XML (Ox), as the name implies was written to provide speed optimized\nXML handling.