Skip to content

load_helps crashes on an empty help keyword that ROM's loader accepts #7

Description

@ctoth

AreaFile.load_helps indexes the keyword before checking it:

https://github.com/ctoth/area_reader/blob/3297b88/area_reader/__init__.py#L380-L389

def load_helps(self):
    while True:
        level = self.read_number()
        keyword = self.read_string()
        if keyword[0] == '$':
            break

A help entry with an empty keyword (5 ~) makes keyword[0] raise IndexError, which the section wrapper re-raises as a generic ParseError. Reproduced:

#HELPS
5 ~
some text~
0 $~
ParseError: ...\h.are line 8 col 3 in section helps: Error reading section 'helps'
(underlying: IndexError from keyword[0])

ROM's C loader accepts this file: fread_string returns an empty string and keyword[0] is '\0', which is not '$', so the help is stored. So this is a file the reference engine loads and area_reader rejects.

Fix: if keyword.startswith('$'):.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions