diff options
author | Bram Moolenaar <bram@vim.org> | 2011-08-04 19:34:59 +0200 |
---|---|---|
committer | Bram Moolenaar <bram@vim.org> | 2011-08-04 19:34:59 +0200 |
commit | 81a0b0e767b958ece67e86ee46d19a6ade9ac160 (patch) | |
tree | 358fa995608a85e27d7523cf72ec916cc2ba5445 | |
parent | 4349fbd2379a33f36a8fbec9c37165c869d5436b (diff) | |
download | vim-81a0b0e767b958ece67e86ee46d19a6ade9ac160.tar.gz |
Problem: Ruby on Mac OS X 10.7 may crash.
Solution: Avoid alloc(0). (Bjorn Winckler)
-rw-r--r-- | src/if_ruby.c | 18 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/if_ruby.c b/src/if_ruby.c index a45269d6..5dc32858 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -761,11 +761,19 @@ 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) + { + /* Only do this when the string isn't empty, alloc(0) causes trouble. */ + buff = ALLOCA_N(char, RSTRING_LEN(str)); + strcpy(buff, RSTRING_PTR(str)); + p = strchr(buff, '\n'); + if (p) *p = '\0'; + MSG(buff); + } + else + { + MSG(""); + } return Qnil; } diff --git a/src/version.c b/src/version.c index f6471cf4..6bddff0c 100644 --- a/src/version.c +++ b/src/version.c @@ -710,6 +710,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 267, +/**/ 266, /**/ 265, |