comparison src/if_ruby.c @ 2990:ad404f2a4bfa v7.3.267

updated for version 7.3.267 Problem: Ruby on Mac OS X 10.7 may crash. Solution: Avoid alloc(0). (Bjorn Winckler)
author Bram Moolenaar <bram@vim.org>
date Thu, 04 Aug 2011 19:34:59 +0200
parents 0c7d6d01e058
children d7b335626ddc
comparison
equal deleted inserted replaced
2989:124a81f12ca4 2990:ad404f2a4bfa
759 static VALUE vim_message(VALUE self UNUSED, VALUE str) 759 static VALUE vim_message(VALUE self UNUSED, VALUE str)
760 { 760 {
761 char *buff, *p; 761 char *buff, *p;
762 762
763 str = rb_obj_as_string(str); 763 str = rb_obj_as_string(str);
764 buff = ALLOCA_N(char, RSTRING_LEN(str)); 764 if (RSTRING_LEN(str) > 0)
765 strcpy(buff, RSTRING_PTR(str)); 765 {
766 p = strchr(buff, '\n'); 766 /* Only do this when the string isn't empty, alloc(0) causes trouble. */
767 if (p) *p = '\0'; 767 buff = ALLOCA_N(char, RSTRING_LEN(str));
768 MSG(buff); 768 strcpy(buff, RSTRING_PTR(str));
769 p = strchr(buff, '\n');
770 if (p) *p = '\0';
771 MSG(buff);
772 }
773 else
774 {
775 MSG("");
776 }
769 return Qnil; 777 return Qnil;
770 } 778 }
771 779
772 static VALUE vim_set_option(VALUE self UNUSED, VALUE str) 780 static VALUE vim_set_option(VALUE self UNUSED, VALUE str)
773 { 781 {