Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out-of-range functions #33

Open
thesourcerer8 opened this issue Jan 25, 2018 · 1 comment
Open

Out-of-range functions #33

thesourcerer8 opened this issue Jan 25, 2018 · 1 comment

Comments

@thesourcerer8
Copy link
Contributor

thesourcerer8 commented Jan 25, 2018

The automatic function detection seems to register also functions that are outside the valid areas. This causes errors when saving the file afterwards:

Traceback (most recent call last):
  File "./ScratchABit.py", line 1032, in <module>
    saveload.save_state(project_dir)
  File "/home/user/scratch/ScratchABit/scratchabit/saveload.py", line 32, in save_state
    engine.ADDRESS_SPACE.save_addr_props(project_dir + "/project.aprops")
  File "/home/user/scratch/ScratchABit/scratchabit/engine.py", line 683, in save_addr_props
    while addr > areas[area_i][END]:
IndexError: list index out of range

The following patch logs the offending function definition:

--- a/scratchabit/engine.py
+++ b/scratchabit/engine.py
@@ -680,8 +680,11 @@ class AddressSpace:
             if addr > area_end:
                 stream.close()
                 area_i += 1
-                while addr > areas[area_i][END]:
+                while area_i<len(areas) and addr > areas[area_i][END]:
                     area_i += 1
+                if area_i>=len(areas):
+                    log.debug("addr not valid (%x,%s)", addr, props.get("label"))
+                assert area_i<len(areas)
@pfalcon
Copy link
Owner

pfalcon commented Jan 27, 2018

I believe this should be fixed by 93b1e21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants