Skip to content

Commit

Permalink
Fixed|DEH Reader: Crash parsing DEH patches referencing unknown defin…
Browse files Browse the repository at this point in the history
…itions

DeHackEd patches are intended for a specific version of a game, which
we may not have default definitions for. In such a case, read into a
dummy definition so at least parsing *should* complete successfully.

Encountered this when regression testing Tango's MBF-compatible mod
"Mayan Mishap" (see: http://www.doomworld.com/vb/wads-mods/70845-mayan-mishap-final-release/)

(Although we don't presently support the MBF feature set, Doomsday
should (ideally) not crash when trying a mod that requires it).
  • Loading branch information
danij-deng committed Nov 29, 2014
1 parent 83db6c4 commit 0503798
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 82 deletions.
16 changes: 13 additions & 3 deletions doomsday/libdoomsday/include/doomsday/defs/dedarray.h
Expand Up @@ -128,6 +128,16 @@ struct LIBDOOMSDAY_PUBLIC DEDArray
return elements[index];
}

PODType const &first() const
{
return at(0);
}

PODType const &last() const
{
return at(size() - 1);
}

/**
* Appends new, zeroed elements to the end of the array.
*
Expand Down Expand Up @@ -199,9 +209,9 @@ struct LIBDOOMSDAY_PUBLIC DEDArray

int indexOf(PODType const *element) const
{
int index = element - elements;
DENG2_ASSERT(index >= 0 && index < size());
return index;
if(size() > 0 && element >= &first() && element <= &last())
return element - elements;
return -1;
}

void clear()
Expand Down

0 comments on commit 0503798

Please sign in to comment.