View Issue Details

IDProjectCategoryView StatusLast Update
0009140Multi Theft Auto : San AndreasClientpublic2016-02-08 11:34
Reporterharon4iggAssigned Toccw 
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformMTA SA 1.5.2OSWindowsOS Version8
Product Version 
Target VersionFixed in Version1.5.2 
Summary0009140: Wrong behavior of fileRead function if bytes request exceed 10000
Description

When you trying to read file using limit of bytes which exceed 10000 bytes, the file handle never reaching end of file and last byte will not be read at all.
Causing to infinity running script error when loading any file.

Steps To Reproduce

function readFile(filePath)
local hFile = fileOpen(filePath)
if hFile then
local buffer = ""
local size = fileGetSize(hFile)
outputDebugString("Reading: " .. filePath .. " bytes: " .. "0/"..size)
while not fileIsEOF(hFile) do
buffer = buffer .. fileRead(hFile, 10001)
outputDebugString("Reading " .. filePath .. " bytes: " .. #buffer .. "/" .. size)
end
fileClose(hFile)

    return buffer
else
    outputConsole("Unable to open: " .. filePath)
end

end

Additional Information

Result:

[2016-02-07 16:17:08] INFO: Reading test.col bytes: 0/177
[2016-02-07 16:17:08] INFO: Reading test.col bytes: 176/177
[2016-02-07 16:17:14] INFO: Reading test.col bytes: 176/177 [DUP x213547]

If using byte limit lower or equal 10000 then every thing is ok.
Seems like this issue relatated to: https://github.com/multitheftauto/mtasa-blue/commit/23f4001f36fc7a5ad50ec85eb9c722c8e52e1ac6

TagsNo tags attached.

Activities

ccw

2016-02-08 07:08

administrator   ~~0024390

Thanks for the example code.

Fixed in https://github.com/multitheftauto/mtasa-blue/commit/9dd823a1eb53cd6af96f2dd762c1d5f812f72792

haron4igg

2016-02-08 11:19

viewer   ~~0024391

Thanks for for fast response! But right now a new error occured...

Same code. Used for loading encrypted dffs, cols and txds.

New error: ERROR: not enough memory

Seems like you made an memory leak:(

ccw

2016-02-08 11:34

administrator   ~~0024392

Please make a resource which shows the problem and upload to
https://upload.mtasa.com/

Issue History

Date Modified Username Field Change