summaryrefslogtreecommitdiff
path: root/src/if_ruby.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2011-08-04 19:34:59 +0200
committerBram Moolenaar <Bram@vim.org>2011-08-04 19:34:59 +0200
commit3f5f795f7656aa986d449d2f72c3d0b4fe4703ed (patch)
tree7f6af21c14b58ae3f4992291b10f4ad0a3a0d914 /src/if_ruby.c
parent673214bb7df95c40ca390b032de100517ac816e1 (diff)
downloadvim-git-3f5f795f7656aa986d449d2f72c3d0b4fe4703ed.tar.gz
updated for version 7.3.267v7.3.267
Problem: Ruby on Mac OS X 10.7 may crash. Solution: Avoid alloc(0). (Bjorn Winckler)
Diffstat (limited to 'src/if_ruby.c')
-rw-r--r--src/if_ruby.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/if_ruby.c b/src/if_ruby.c
index a45269d6e..5dc32858b 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;
}