diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-24 01:25:02 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-24 01:25:02 +0000 |
commit | 152934a300d8becb43d7d260b8491d162cbd83ba (patch) | |
tree | 51b8eba43b07188e24300537f09784c6518103e5 /file.c | |
parent | 064c36a04113170df97af12ed54c5e1e636a849e (diff) |
* file.c (file_expand_path): set length of string before calling
rb_enc_check because rb_enc_check scans its content.
This prevents warnings by valgrind.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -2849,11 +2849,14 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) p = chompdirsep(skiproot(buf)); } else { + size_t len; b = s; do s++; while (isdirsep(*s)); - p = buf + (s - b); + len = s - b; + p = buf + len; BUFCHECK(bdiff >= buflen); - memset(buf, '/', p - buf); + memset(buf, '/', len); + rb_str_set_len(result, len); rb_enc_associate(result, rb_enc_check(result, fname)); } if (p > buf && p[-1] == '/') |