Skip to content

Commit 3fa73d4

Browse files
committed
FileAccessMemory: prevent seeking past end of file
1 parent 36b9212 commit 3fa73d4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/io/file_access_memory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ bool FileAccessMemory::is_open() const {
9898

9999
void FileAccessMemory::seek(uint64_t p_position) {
100100
ERR_FAIL_NULL(data);
101+
ERR_FAIL_COND(p_position > length);
101102
pos = p_position;
102103
}
103104

104105
void FileAccessMemory::seek_end(int64_t p_position) {
105106
ERR_FAIL_NULL(data);
106-
pos = length + p_position;
107+
ERR_FAIL_COND((int64_t)length + p_position < 0);
108+
seek(length + p_position);
107109
}
108110

109111
uint64_t FileAccessMemory::get_position() const {

0 commit comments

Comments
 (0)