mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
Lunatic: fix map-text loading.
The file descriptor was closed from Lua code, causing the subsequent kfilelength() to fail and attempt an allocation of (size_t)-1 bytes. git-svn-id: https://svn.eduke32.com/eduke32@5809 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
f0cb3ea994
commit
edd7a82be8
2 changed files with 4 additions and 6 deletions
|
@ -1705,7 +1705,9 @@ local function readintostr_mod(fn)
|
|||
return nil
|
||||
end
|
||||
|
||||
return defs_c.readintostr(fd)
|
||||
local ret = defs_c.readintostr(fd)
|
||||
ffiC.kclose(fd)
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -399,26 +399,22 @@ int32_t sectorofwall_noquick(int16_t theline);
|
|||
]]
|
||||
|
||||
-- Reads the whole file given by the k* file descriptor into a Lua string.
|
||||
-- Always closes the file descriptor.
|
||||
-- Does not close the file descriptor.
|
||||
function readintostr(fd, kopen4load_func)
|
||||
-- XXX: this is pretty much the same as the code in L_RunOnce()
|
||||
|
||||
local sz = ffiC.kfilelength(fd)
|
||||
if (sz == 0) then
|
||||
ffiC.kclose(fd)
|
||||
return ""
|
||||
end
|
||||
|
||||
if (sz < 0) then
|
||||
ffi.kclose(fd)
|
||||
error("INTERNAL ERROR: kfilelength() returned negative length")
|
||||
end
|
||||
|
||||
local str = ffi.new("char [?]", sz)
|
||||
local readlen = ffiC.kread(fd, str, sz)
|
||||
|
||||
ffiC.kclose(fd); fd=-1
|
||||
|
||||
if (readlen ~= sz) then
|
||||
error("INTERNAL ERROR: couldn't read file wholly")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue