Skip to content
Browse files

Fix segfaults in the array parser using RB_GC_GUARD, bump version to …

…1.5.1
  • Loading branch information...
1 parent 86847f7 commit 15edb132887d9b5292cad419fc7692ed5cd4b01b @jeremyevans committed
Showing with 10 additions and 2 deletions.
  1. +4 −0 CHANGELOG
  2. +5 −1 ext/sequel_pg/sequel_pg.c
  3. +1 −1 sequel_pg.gemspec
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+=== 1.5.1 (2012-08-02)
+
+* Sprinkle some RB_GC_GUARD to work around segfaults in the PostgreSQL array parser (jeremyevans)
+
=== 1.5.0 (2012-07-02)
* Add C-based PostgreSQL array parser, for major speedup in parsing arrays (Dan McClain, jeremyevans)
View
6 ext/sequel_pg/sequel_pg.c
@@ -133,6 +133,7 @@ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_le
int escapeNext = 0;
VALUE array = rb_ary_new();
+ RB_GC_GUARD(array);
/* Special case the empty array, so it doesn't need to be handled manually inside
* the loop. */
@@ -156,7 +157,9 @@ static VALUE read_array(int *index, char *c_pg_array_string, int array_string_le
}
else if (RTEST(converter))
{
- rb_ary_push(array, rb_funcall(converter, spg_id_call, 1, rb_str_new(word, word_index)));
+ VALUE rword = rb_str_new(word, word_index);
+ RB_GC_GUARD(rword);
+ rb_ary_push(array, rb_funcall(converter, spg_id_call, 1, rword));
}
else
{
@@ -217,6 +220,7 @@ static VALUE parse_pg_array(VALUE self, VALUE pg_array_string, VALUE converter)
char *c_pg_array_string = StringValueCStr(pg_array_string);
int array_string_length = RSTRING_LEN(pg_array_string);
VALUE buf = rb_str_buf_new(array_string_length);
+ RB_GC_GUARD(buf);
char *word = RSTRING_PTR(buf);
int index = 1;
View
2 sequel_pg.gemspec
@@ -1,6 +1,6 @@
SEQUEL_PG_GEMSPEC = Gem::Specification.new do |s|
s.name = 'sequel_pg'
- s.version = '1.5.0'
+ s.version = '1.5.1'
s.platform = Gem::Platform::RUBY
s.has_rdoc = false
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG", "MIT-LICENSE"]

0 comments on commit 15edb13

Please sign in to comment.
Something went wrong with that request. Please try again.