Skip to content

Commit

Permalink
Emergency fix for Ruby problems
Browse files Browse the repository at this point in the history
With optimizations enabled "alloca(len)" generates code which depends on
"len > 0".  If "len == 0" then the stack pointer becomes botched.  This
fix simply avoids a call to "alloca(len)" in the latter case.  The root
of this problem may be deeper than this, hence I am calling this an
"emergency fix" for now but at least it fixes the crashes in the Ruby
interface that appear when compiling on Mac OS X 10.7.
  • Loading branch information
b4winckler committed Jul 22, 2011
1 parent 301fd4c commit 27086e3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/if_ruby.c
Expand Up @@ -765,11 +765,14 @@ static VALUE vim_message(VALUE self UNUSED, VALUE str)
char *buff, *p;

str = rb_obj_as_string(str);
buff = ALLOCA_N(char, RSTRING_LEN(str));
strcpy(buff, RSTRING_PTR(str));
p = strchr(buff, '\n');
if (p) *p = '\0';
MSG(buff);
if (RSTRING_LEN(str) > 0)
{
buff = ALLOCA_N(char, RSTRING_LEN(str));
strcpy(buff, RSTRING_PTR(str));
p = strchr(buff, '\n');
if (p) *p = '\0';
MSG(buff);
}
return Qnil;
}

Expand Down

0 comments on commit 27086e3

Please sign in to comment.