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
This commit is contained in:
parent
b74131132f
commit
23c74845ed
5
ruby.c
5
ruby.c
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user