Re: luajit 2.1 table.sort segmentation fault on OSX and Linux

  • From: Florian Weimer <fw@xxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 20 Mar 2014 09:45:55 +0100

* ivan starkov:

>   local any_struct_ffi = ffi.new("some_struct[?]", 10)
>
>   for i=0, 10 do
>     sorted[i] = 10-i
>     any_struct_ffi[i].value = i
>   end

This looks like an out-of-bounds.  You allocate 10 elements,
(any_struct_ffi[0] to any_struct_ffi[9]), but you write to
any_struct_ffi[10] as well.

Other related posts: