Page MenuHomeFeedback Tracker

[Resolved] FileHandle::ReadFile causes an illegal read
Closed, ResolvedPublic

Description

When executing the code below the FileHandle::ReadFile method reading into an int fails. I tried reading with sizes 1 and 4, both with the same result.
User error: We are supposed to pass in an array, not a singular value. So read of int readByte[1]; with the reading size of 4 works as intended.

Reason: Access violation. Illegal write by 0x7ffcbcb1140c at 0x0

Class: 'UF_SelfExecute'
Function: 'TestLoad'

[memcpy]: ??? addr:0x7ffcbcb1140c
[zlibVersion]: ??? addr:0x7ff621c50eef
[zlibVersion]: ??? addr:0x7ff621c50c46

class UF_SelfExecute
{
	static const ref UF_SelfExecute m_pSelfInstance = new UF_SelfExecute();

	void UF_SelfExecute()
	{
		TestSave();
		TestLoad();
	}

	void TestSave()
	{
		FileSerializer file();
		int bytes[3] = {1, 42, 1337};

		if (file.Open("test.bin", FileMode.WRITE))
		{
			file.Write(bytes);
			file.Close();
		}
	}

	void TestLoad()
	{
		FileHandle handle = FileIO.OpenFile("test.bin", FileMode.READ);

		if (handle)
		{
			int readByte;
			for(int n = 0; n < 5; n++)
			{
				PrintFormat("Read: %1 - Value: %2", handle.ReadFile(readByte, 4), readByte); // <----------- crash caused by this line
			}

			handle.CloseFile();
		}
	}
}

Details

Severity
Crash
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General

Event Timeline

Arkensor created this task.Oct 14 2022, 3:06 PM
Arkensor updated the task description. (Show Details)
Arkensor renamed this task from FileHandle::ReadFile causes an illegal read to [Resolved] FileHandle::ReadFile causes an illegal read.Oct 14 2022, 3:32 PM
Arkensor updated the task description. (Show Details)

Geez, this can be closed and or deleted, turns out it was a misuse of the API after internal feedback. Sorry >.>

Geez closed this task as Resolved.Oct 14 2022, 4:07 PM
Geez claimed this task.