Skip to content

Commit

Permalink
Fix memory leak with BB.fromstring()
Browse files Browse the repository at this point in the history
  • Loading branch information
poire-z authored and Frenzie committed May 23, 2017
1 parent b7d41fa commit 80ce401
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ffi/blitbuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,9 @@ end
function BB.fromstring(width, height, buffertype, str, pitch)
local dataptr = ffi.C.malloc(#str)
ffi.copy(dataptr, str, #str)
return BB.new(width, height, buffertype, dataptr, pitch)
local bb = BB.new(width, height, buffertype, dataptr, pitch)
bb:setAllocated(1)
return bb
end

function BB.tostring(bb)
Expand Down

0 comments on commit 80ce401

Please sign in to comment.