summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-10 07:17:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-10 07:17:53 +0000
commit683400f4278fe0db00592c06522979be845bcc45 (patch)
treeb10b6489ef3dee4fc819499d3731bc66f8b8f21e /string.c
parent63b9174a64ab16045924d5ec053303b81e91dc16 (diff)
* dir.c (rb_glob2): do not allocate buffer from heap to avoid
memory leaks. use string object for buffering instead. [ruby-dev:24738] * dir.c (join_path): ditto. * io.c (io_read): external input buffer may be modified even after rb_str_locktmp(). [ruby-dev:24735] * dir.c (fnmatch): p or s may be NULL. [ruby-dev:24749] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/string.c b/string.c
index ac3efa3c5f..3df8fb9555 100644
--- a/string.c
+++ b/string.c
@@ -252,13 +252,6 @@ rb_str_shared_replace(str, str2)
if (str == str2) return;
rb_str_modify(str);
if (!FL_TEST(str, ELTS_SHARED)) free(RSTRING(str)->ptr);
- if (NIL_P(str2)) {
- RSTRING(str)->ptr = 0;
- RSTRING(str)->len = 0;
- RSTRING(str)->aux.capa = 0;
- FL_UNSET(str, STR_NOCAPA);
- return;
- }
RSTRING(str)->ptr = RSTRING(str2)->ptr;
RSTRING(str)->len = RSTRING(str2)->len;
FL_UNSET(str, STR_NOCAPA);
@@ -640,6 +633,9 @@ VALUE
rb_str_locktmp(str)
VALUE str;
{
+ if (FL_TEST(str, STR_TMPLOCK)) {
+ rb_raise(rb_eRuntimeError, "temporal locking already locked string");
+ }
FL_SET(str, STR_TMPLOCK);
return str;
}
@@ -648,6 +644,9 @@ VALUE
rb_str_unlocktmp(str)
VALUE str;
{
+ if (!FL_TEST(str, STR_TMPLOCK)) {
+ rb_raise(rb_eRuntimeError, "temporal unlocking already unlocked string");
+ }
FL_UNSET(str, STR_TMPLOCK);
return str;
}
@@ -2278,7 +2277,8 @@ rb_str_clear(str)
}
RSTRING(str)->aux.shared = 0;
FL_UNSET(str, STR_NOCAPA);
- RSTRING(str)->ptr = 0;
+ FL_SET(str, ELTS_SHARED);
+ RSTRING(str)->ptr = null_str;
RARRAY(str)->len = 0;
return str;
}