diff --git a/ChangeLog b/ChangeLog index f7aed29a14..f6812d0ada 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Mar 24 10:18:12 2010 NARUSE, Yui + + * 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 * lib/csv.rb: Incorporating the fixes from the recent diff --git a/file.c b/file.c index 7d6d25e21a..5a0b16eabe 100644 --- a/file.c +++ b/file.c @@ -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] == '/')