diff options
author | ZyX <kp-pav@yandex.ru> | 2016-06-23 22:25:35 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-06-24 00:07:56 +0300 |
commit | a3b05a03b62b2c5be92a63ba3890b0359a335ba7 (patch) | |
tree | 663f7369d68ce90e483c336a1a7de478781ab111 /test/unit/os/fs_spec.lua | |
parent | 2dd154457ceb4bbc122b9e1ad34bf693ee3dd510 (diff) | |
download | rneovim-a3b05a03b62b2c5be92a63ba3890b0359a335ba7.tar.gz rneovim-a3b05a03b62b2c5be92a63ba3890b0359a335ba7.tar.bz2 rneovim-a3b05a03b62b2c5be92a63ba3890b0359a335ba7.zip |
unittests: Fix bug somewhere that makes file_read tests SEGV
Diffstat (limited to 'test/unit/os/fs_spec.lua')
-rw-r--r-- | test/unit/os/fs_spec.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index 1f7f6fb791..cc10b0cfa4 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -378,12 +378,16 @@ describe('fs function', function() local function os_close(fd) return fs.os_close(fd) end + -- For some reason if length of NUL-bytes-string is the same as `char[?]` + -- size luajit crashes. Though it does not do so in this test suite, better + -- be cautios and allocate more elements then needed. I only did this to + -- strings. local function os_read(fd, size) local buf = nil if size == nil then size = 0 else - buf = ffi.new('char[?]', size, ('\0'):rep(size)) + buf = ffi.new('char[?]', size + 1, ('\0'):rep(size)) end local eof = ffi.new('bool[?]', 1, {true}) local ret2 = fs.os_read(fd, eof, buf, size) @@ -398,7 +402,7 @@ describe('fs function', function() local bufs = {} for i, size in ipairs(sizes) do bufs[i] = { - iov_base=ffi.new('char[?]', size, ('\0'):rep(size)), + iov_base=ffi.new('char[?]', size + 1, ('\0'):rep(size)), iov_len=size, } end |