* ruby.c (ruby_init_loadpath_safe): should not dup tmp string. a

patch from neomjp neomjp in [ruby-core:24251].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-10-18 09:32:02 +00:00
Родитель d08d73b47d
Коммит d68e5dce35
2 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sun Oct 18 18:31:58 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (ruby_init_loadpath_safe): should not dup tmp string. a
patch from neomjp neomjp in [ruby-core:24251].
Sun Oct 18 09:49:14 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp> Sun Oct 18 09:49:14 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
* test/test_prime.rb * test/test_prime.rb

11
ruby.c
Просмотреть файл

@ -350,8 +350,8 @@ ruby_init_loadpath_safe(int safe_level)
VALUE sopath; VALUE sopath;
# else # else
char libpath[MAXPATHLEN + 1]; char libpath[MAXPATHLEN + 1];
size_t baselen;
# endif # endif
size_t baselen;
char *p; char *p;
#if defined _WIN32 || defined __CYGWIN__ #if defined _WIN32 || defined __CYGWIN__
@ -416,16 +416,13 @@ ruby_init_loadpath_safe(int safe_level)
strlcpy(libpath, ".", sizeof(libpath)); strlcpy(libpath, ".", sizeof(libpath));
p = libpath + 1; p = libpath + 1;
} }
baselen = p - libpath;
#define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen)
#else #else
rb_str_set_len(sopath, p - libpath); rb_str_set_len(sopath, p - libpath);
#define BASEPATH() rb_str_dup(sopath)
#endif #endif
baselen = p - libpath;
#define BASEPATH() rb_str_buf_cat(rb_str_buf_new(baselen+len), libpath, baselen)
#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), path, len) #define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), path, len)
#else #else
#define RUBY_RELATIVE(path, len) rubylib_mangled_path(path, len) #define RUBY_RELATIVE(path, len) rubylib_mangled_path(path, len)