Re: LuaJIT Crash When Returning Null Pointer from FFI

  • From: Mike Pall <mike-1407@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 22 Jul 2014 21:23:57 +0200

Jim Burnes wrote:
> Mike Pall wrote:
> >This function is only called if you're indexing the returned
> >pointer yourself. For example by accessing fd.fd in a __tostring
> >metamethod.
> I am using __tostring on it.  So am I prevented from using metamethods when
> returning NULLs or should I used some other technique?

No, you can use __tostring. But you better check for a NULL
pointer before dereferencing a field.

I mean, you wrote that method, right? The default __tostring
handler of the FFI doesn't dereference pointers, so it must be
your code.

--Mike

Other related posts: