1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 01:29:49 +00:00

Fix potential index out of bounds error (#446)

This commit is contained in:
kleonc 2021-01-30 18:30:02 +01:00 committed by GitHub
parent 27852b2694
commit 499251f44a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -529,19 +529,21 @@ func remove_backup_by_path(project_path : String, backup_path : String) -> void:
func reload_backup_file(project_paths : Array, backup_paths : Array) -> void: func reload_backup_file(project_paths : Array, backup_paths : Array) -> void:
assert(project_paths.size() == backup_paths.size())
# Clear non-existant backups # Clear non-existant backups
var deleted_backup_paths := [] var existing_backups_count := 0
var dir := Directory.new() var dir := Directory.new()
for backup in backup_paths: for i in range(backup_paths.size()):
if !dir.file_exists(backup): if dir.file_exists(backup_paths[i]):
if Global.config_cache.has_section_key("backups", backup): project_paths[existing_backups_count] = project_paths[i]
Global.config_cache.erase_section_key("backups", backup) backup_paths[existing_backups_count] = backup_paths[i]
existing_backups_count += 1
else:
if Global.config_cache.has_section_key("backups", backup_paths[i]):
Global.config_cache.erase_section_key("backups", backup_paths[i])
Global.config_cache.save("user://cache.ini") Global.config_cache.save("user://cache.ini")
project_paths.remove(backup_paths.find(backup)) project_paths.resize(existing_backups_count)
deleted_backup_paths.append(backup) backup_paths.resize(existing_backups_count)
for deleted in deleted_backup_paths:
backup_paths.erase(deleted)
# Load the backup files # Load the backup files
for i in range(project_paths.size()): for i in range(project_paths.size()):