 <p><code>tostring</code> is being passed an address, and so gives you the string representation of that address. You need <code>ffi.string</code> instead.</p> <pre><code>local str = ffi.string(ffi.C.getString(5)) </code></pre> <p>Now <code>str</code> is a Lua string containing what was returned by your Pascal code.</p> <p>Your other perhaps bigger problem is surely that you are allocating a string on the Pascal module's heap with no obvious way of deallocating it.</p>