server-beta icon indicating copy to clipboard operation
server-beta copied to clipboard

[BUG]: `fread` used with already closed handle crashes the server

Open Zbyss opened this issue 3 years ago • 0 comments

Description

I know that's not something that should be done, but on SA-MP server during this situation, fread just returns 0 and later on, everything works properly. Scripts that accidentally do it crash on open.mp server without any details about the problem. Some warning about this issue would be useful.

How to re-produce this bug

#include <a_samp>

main(){}

public OnGameModeInit()
{
	new
		File:handle = fopen("list.txt", io_read),
		string[128];
	
	fclose(handle);
	fread(handle, string);

	return print("Hello world!");
}

Make sure you have list.txt file in scriptfiles directory.

Relevant log output

N/A

open.mp server version

open.mp server public beta build 7

Operating system or distribution

Microsoft Windows 11 64-bit

Contact information

Zbyss.#2597

Additional information

I can't provide the crash dump, as it's not generated in this case.

Zbyss avatar Jul 15 '22 21:07 Zbyss