From 0b5119e4f491bcdf77465c097487a3f290417db3 Mon Sep 17 00:00:00 2001
From: Drombeys <dima.zolotov02@gmail.com>
Date: Tue, 7 Mar 2023 18:35:42 +0300
Subject: [PATCH] Fix accessing to current object

---
 src/xrCore/FS.cpp                       | 7 +++++--
 src/xr_3da/xrGame/space_restriction.cpp | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/xrCore/FS.cpp b/src/xrCore/FS.cpp
index a6b4c401..506bb315 100644
--- a/src/xrCore/FS.cpp
+++ b/src/xrCore/FS.cpp
@@ -281,8 +281,11 @@ IReader*	IReader::open_chunk(u32 ID)
 		}
 	} else return 0;
 };
-void	IReader::close()
-{	xr_delete((IReader*)this); }
+
+void IReader::close() {
+    auto pointer = (IReader*) this;
+    xr_delete(pointer);
+}
 
 IReader*	IReader::open_chunk_iterator	(u32& ID, IReader* _prev)
 {
diff --git a/src/xr_3da/xrGame/space_restriction.cpp b/src/xr_3da/xrGame/space_restriction.cpp
index ee7d2e5f..f40aec48 100644
--- a/src/xr_3da/xrGame/space_restriction.cpp
+++ b/src/xr_3da/xrGame/space_restriction.cpp
@@ -312,8 +312,9 @@ void CSpaceRestriction::remove_border			()
 
 u32	CSpaceRestriction::accessible_nearest		(const Fvector &position, Fvector &result)
 {
+	auto pointer = this;
 	if (m_out_space_restriction)
-		return						(m_out_space_restriction->accessible_nearest(this,position,result,true));
+		return						(m_out_space_restriction->accessible_nearest(pointer, position, result, true));
 
 	VERIFY							(m_in_space_restriction);
 	return							(m_in_space_restriction->accessible_nearest(m_in_space_restriction,position,result,false));