From e58230d5061191756248e2e020910a23afb63b33 Mon Sep 17 00:00:00 2001 From: QAston Date: Wed, 24 Jun 2009 01:50:59 +0200 Subject: [PATCH] *Add security check to Vehicle::InstallAccessory. --HG-- branch : trunk --- src/game/Vehicle.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp index 0aa0d48a24..54bb5275f4 100644 --- a/src/game/Vehicle.cpp +++ b/src/game/Vehicle.cpp @@ -266,10 +266,17 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId) if(!accessory) return; - accessory->m_Vehicle = this; - AddPassenger(accessory, seatId); - // This is not good, we have to send update twice - accessory->SendMovementFlagUpdate(); + if (!accessory->m_Vehicle) + { + accessory->m_Vehicle = this; + if (!AddPassenger(accessory, seatId)) + { + accessory->m_Vehicle = NULL; + return; + } + // This is not good, we have to send update twice + accessory->SendMovementFlagUpdate(); + } } bool Vehicle::AddPassenger(Unit *unit, int8 seatId)