summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/string.c b/string.c
index 8a8a0d4..48cd779 100644
--- a/string.c
+++ b/string.c
@@ -464,6 +464,7 @@ str_independent(str)
VALUE str;
{
if (FL_TEST(str, STR_TMPLOCK)) {
+ FL_UNSET(str, STR_TMPLOCK);
rb_raise(rb_eRuntimeError, "can't modify string; temporarily locked");
}
if (OBJ_FROZEN(str)) rb_error_frozen("string");
@@ -2064,6 +2065,8 @@ str_gsub(argc, argv, str, bang)
bp = buf;
cp = RSTRING(str)->ptr;
+ rb_str_locktmp(str);
+ rb_str_locktmp(dest);
while (beg >= 0) {
n++;
match = rb_backref_get();
@@ -2121,6 +2124,8 @@ str_gsub(argc, argv, str, bang)
}
rb_backref_set(match);
*bp = '\0';
+ rb_str_unlocktmp(str);
+ rb_str_unlocktmp(dest);
if (bang) {
if (str_independent(str)) {
free(RSTRING(str)->ptr);
@@ -4417,7 +4422,7 @@ rb_str_sum(argc, argv, str)
return sum;
}
else {
- unsigned int sum = 0;
+ unsigned long sum = 0;
while (p < pend) {
str_mod_check(str, ptr, len);
@@ -4425,7 +4430,7 @@ rb_str_sum(argc, argv, str)
p++;
}
if (bits != 0) {
- sum &= (1<<bits)-1;
+ sum &= (((unsigned long)1)<<bits)-1;
}
return rb_int2inum(sum);
}