1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
naruse 2010-03-24 01:25:02 +00:00
parent 064c36a041
commit 152934a300
2 changed files with 11 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Wed Mar 24 10:18:12 2010 NARUSE, Yui <naruse@ruby-lang.org>
* 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.
Tue Mar 23 23:58:51 2010 James Edward Gray II <jeg2@ruby-lang.org> Tue Mar 23 23:58:51 2010 James Edward Gray II <jeg2@ruby-lang.org>
* lib/csv.rb: Incorporating the fixes from the recent * lib/csv.rb: Incorporating the fixes from the recent

7
file.c
View file

@ -2849,11 +2849,14 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
p = chompdirsep(skiproot(buf)); p = chompdirsep(skiproot(buf));
} }
else { else {
size_t len;
b = s; b = s;
do s++; while (isdirsep(*s)); do s++; while (isdirsep(*s));
p = buf + (s - b); len = s - b;
p = buf + len;
BUFCHECK(bdiff >= buflen); 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)); rb_enc_associate(result, rb_enc_check(result, fname));
} }
if (p > buf && p[-1] == '/') if (p > buf && p[-1] == '/')