Skip to content

Commit 24dfc91

Browse files
committed
Fix the json parser failure with GCC 4.7
1 parent 824be2c commit 24dfc91

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

ruby-1.9.3-fix-json-parser.patch

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
2+
index d1d14c7..1773616 100644
3+
--- a/ext/json/parser/parser.c
4+
+++ b/ext/json/parser/parser.c
5+
@@ -1293,6 +1293,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
6+
{
7+
char *p = string, *pe = string, *unescape;
8+
int unescape_len;
9+
+ char buf[4];
10+
11+
while (pe < stringEnd) {
12+
if (*pe == '\\') {
13+
@@ -1325,7 +1326,6 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
14+
if (pe > stringEnd - 4) {
15+
return Qnil;
16+
} else {
17+
- char buf[4];
18+
UTF32 ch = unescape_unicode((unsigned char *) ++pe);
19+
pe += 3;
20+
if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
21+
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
22+
index e7d47e1..33e775c 100644
23+
--- a/ext/json/parser/parser.rl
24+
+++ b/ext/json/parser/parser.rl
25+
@@ -393,6 +393,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
26+
{
27+
char *p = string, *pe = string, *unescape;
28+
int unescape_len;
29+
+ char buf[4];
30+
31+
while (pe < stringEnd) {
32+
if (*pe == '\\') {
33+
@@ -425,7 +426,6 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
34+
if (pe > stringEnd - 4) {
35+
return Qnil;
36+
} else {
37+
- char buf[4];
38+
UTF32 ch = unescape_unicode((unsigned char *) ++pe);
39+
pe += 3;
40+
if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {

ruby.spec

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ Patch9: rubygems-1.8.11-binary-extensions.patch
8585
# Fixes segfaults when build with GCC 4.7.
8686
# http://bugs.ruby-lang.org/issues/5851
8787
Patch10: ruby-1.9.3-prevent-optimizing-sp.patch
88+
# Fixes json encoding failures when build with GCC 4.7.
89+
# http://bugs.ruby-lang.org/issues/5888
90+
Patch11: ruby-1.9.3-fix-json-parser.patch
8891

8992
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
9093
Requires: ruby(rubygems) >= %{rubygems_version}
@@ -285,6 +288,7 @@ Tcl/Tk interface for the object-oriented scripting language Ruby.
285288
%patch8 -p1
286289
%patch9 -p1
287290
%patch10
291+
%patch11 -p1
288292

289293
%build
290294
autoconf

0 commit comments

Comments
 (0)