diff --git a/src/decallib.cpp b/src/decallib.cpp index f4af8dc1f..56705c903 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -1121,16 +1121,19 @@ FDecalLib::FTranslation *FDecalLib::FTranslation::LocateTranslation (DWORD start const FDecalTemplate *FDecalGroup::GetDecal () const { const FDecalBase *decal = Choices.PickEntry (); - const FDecalBase *remember; + const FDecalBase *remember = decal; // Repeatedly GetDecal() until the result is constant, since // the choice might be another FDecalGroup. - do + if (decal != NULL) { - remember = decal; - decal = decal->GetDecal (); - } while (decal != remember); - return static_cast(decal); + do + { + remember = decal; + decal = decal->GetDecal (); + } while (decal != NULL && decal != remember); + } + return static_cast(remember); } FDecalAnimator::FDecalAnimator (const char *name) diff --git a/src/weightedlist.h b/src/weightedlist.h index 056a871f8..160e0cd54 100644 --- a/src/weightedlist.h +++ b/src/weightedlist.h @@ -111,7 +111,7 @@ T TWeightedList::PickEntry () const { choice = choice->Next; } - return choice->Value; + return choice != NULL ? choice->Value : NULL; } template