diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-01-31 20:15:30 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-01-31 20:15:30 +0100 |
commit | 37badc898b8d167e11553b6d05908ffd35928a6e (patch) | |
tree | 20206aeb029b4b498c92f1976b618445080da3fb /src | |
parent | cada78975eebc47f9b12de1a471639b5afd9ad2f (diff) | |
download | vim-git-37badc898b8d167e11553b6d05908ffd35928a6e.tar.gz |
patch 8.0.1448: segfault with exception inside :rubyfile commandv8.0.1448
Problem: Segmentation fault when Ruby throws an exception inside :rubyfile
command.
Solution: Use rb_protect() instead of rb_load_protect(). (ujihisa,
closes #2147, greywolf, closes #2512, #2511)
Diffstat (limited to 'src')
-rw-r--r-- | src/if_ruby.c | 15 | ||||
-rw-r--r-- | src/testdir/test_ruby.vim | 8 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/if_ruby.c b/src/if_ruby.c index ca31c1a05..5905424a3 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -377,7 +377,7 @@ static unsigned long (*dll_rb_num2uint) (VALUE); # endif static VALUE (*dll_rb_lastline_get) (void); static void (*dll_rb_lastline_set) (VALUE); -static void (*dll_rb_protect) (VALUE (*)(VALUE), int, int*); +static VALUE (*dll_rb_protect) (VALUE (*)(VALUE), VALUE, int*); static void (*dll_rb_load) (VALUE, int); static long (*dll_rb_num2long) (VALUE); static unsigned long (*dll_rb_num2ulong) (VALUE); @@ -828,15 +828,22 @@ void ex_rubydo(exarg_T *eap) } } +VALUE rb_load_wrap(VALUE file_to_load) +{ + rb_load(file_to_load, 0); + return Qnil; +} + void ex_rubyfile(exarg_T *eap) { int state; if (ensure_ruby_initialized()) { - rb_protect((VALUE (*)(VALUE))rb_load, rb_str_new2((char *)eap->arg), - &state); - if (state) error_print(state); + VALUE file_to_load = rb_str_new2((const char *)eap->arg); + rb_protect(rb_load_wrap, file_to_load, &state); + if (state) + error_print(state); } } diff --git a/src/testdir/test_ruby.vim b/src/testdir/test_ruby.vim index 174467f71..0017f73ae 100644 --- a/src/testdir/test_ruby.vim +++ b/src/testdir/test_ruby.vim @@ -49,3 +49,11 @@ func Test_rubydo() bwipe! bwipe! endfunc + +func Test_rubyfile() + " Check :rubyfile does not SEGV with Ruby level exception but just fails + let tempfile = tempname() . '.rb' + call writefile(['raise "vim!"'], tempfile) + call assert_fails('rubyfile ' . tempfile) + call delete(tempfile) +endfunc diff --git a/src/version.c b/src/version.c index 94d58f84f..1da5bbdc3 100644 --- a/src/version.c +++ b/src/version.c @@ -772,6 +772,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1448, +/**/ 1447, /**/ 1446, |