Skip to content

Commit

Permalink
orderDroidBase: Fix possible crash if getModuleStat fails
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jul 17, 2023
1 parent e816b67 commit 1ce7aba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,9 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
{
break;
}
psDroid->order = DroidOrder(DORDER_BUILD, getModuleStat((STRUCTURE *)psOrder->psObj), psOrder->psObj->pos.xy(), 0);
ASSERT_OR_RETURN(, psDroid->order.psStats != nullptr, "should have found a module stats");
STRUCTURE_STATS *psStats = getModuleStat((STRUCTURE *)psOrder->psObj);
ASSERT_OR_RETURN(, psStats != nullptr, "should have found a module stats");
psDroid->order = DroidOrder(DORDER_BUILD, psStats, psOrder->psObj->pos.xy(), 0);
ASSERT_OR_RETURN(, !psDroid->order.psStats || psDroid->order.psStats->type != REF_DEMOLISH, "Cannot build demolition");
actionDroid(psDroid, DACTION_BUILD, psOrder->psObj->pos.x, psOrder->psObj->pos.y);
objTrace(psDroid->id, "Starting new upgrade of %s", psOrder->psStats ? getStatsName(psOrder->psStats) : "NULL");
Expand Down

0 comments on commit 1ce7aba

Please sign in to comment.