summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-12 08:17:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-12 08:17:53 +0000
commit98d4159e9065357d29f388be7b5d2c5643226ee7 (patch)
tree705c72fa931cefc43d9930f87713feb2275e27b7 /ext
parent3e8706523b1282078f5acfc7b4ee7d013bf5b78f (diff)
downloadruby-98d4159e9065357d29f388be7b5d2c5643226ee7.tar.gz
ruby-98d4159e9065357d29f388be7b5d2c5643226ee7.tar.xz
ruby-98d4159e9065357d29f388be7b5d2c5643226ee7.zip
* ext/stringio/stringio.c (strio_ungetc): calculates new position
before reallocation. [Bug#1099] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/stringio/stringio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 4ff0e36c6..ce1d55fd4 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -728,8 +728,9 @@ strio_ungetc(VALUE self, VALUE c)
p += clen;
lpos++;
}
+ clen = p - RSTRING_PTR(ptr->string);
rb_str_update(ptr->string, lpos, ptr->pos ? 1 : 0, c);
- ptr->pos = p - RSTRING_PTR(ptr->string);
+ ptr->pos = clen;
return Qnil;
}