diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-10 02:54:04 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-10 02:54:04 +0000 |
commit | 23c74845eda6cab10ac3b5e1b98e75fc73bfde75 (patch) | |
tree | 7d51a18a8a4f781a50848ed54aefe46dee954c83 /ruby.c | |
parent | b74131132f8872d23e405c61ecfe18dece17292f (diff) | |
download | ruby-23c74845eda6cab10ac3b5e1b98e75fc73bfde75.tar.gz |
RSTRING_PTR is not guaranteed to be char*-aligned
We need to ensure aligned memory access by allocating
another memory region.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r-- | ruby.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -759,6 +759,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt) char **argv, *p; const char *ap = 0; VALUE argstr, argary; + void *ptr; while (ISSPACE(*s)) s++; if (!*s) return; @@ -781,7 +782,8 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt) argc = RSTRING_LEN(argary) / sizeof(ap); ap = 0; rb_str_cat(argary, (char *)&ap, sizeof(ap)); - argv = (char **)RSTRING_PTR(argary); + argv = ptr = ALLOC_N(char *, argc); + MEMMOVE(argv, RSTRING_PTR(argary), char *, argc); while ((i = proc_options(argc, argv, opt, envopt)) > 1 && envopt && (argc -= i) > 0) { argv += i; @@ -794,6 +796,7 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt) } } + ruby_xfree(ptr); /* get rid of GC */ rb_str_resize(argary, 0); rb_str_resize(argstr, 0); |