Permalink
Browse files

fix leak when buying items from a store

  • Loading branch information...
1 parent 245c5ee commit 73760ee3988152e01b0a5714cdbf982a4f53620f @fizzet fizzet committed May 7, 2013
Showing with 9 additions and 3 deletions.
  1. +5 −2 gemrb/core/Store.cpp
  2. +3 −1 gemrb/core/Store.h
  3. +1 −0 gemrb/plugins/GUIScript/GUIScript.cpp
View
7 gemrb/core/Store.cpp
@@ -33,6 +33,11 @@
namespace GemRB {
+STOItem::~STOItem(void)
+{
+ if (trigger) trigger->Release();
+}
+
Store::Store(void)
{
HasTriggers = false;
@@ -48,8 +53,6 @@ Store::~Store(void)
unsigned int i;
for (i = 0; i < items.size(); i++) {
- if (items[i]->trigger)
- items[i]->trigger->Release();
delete( items[i] );
}
if(drinks)
View
4 gemrb/core/Store.h
@@ -65,7 +65,7 @@ STA_CURE=3, STA_DONATE=4, STA_DRINK=5, STA_ROOMRENT=6, STA_OPTIONAL=0x80} StoreA
* @struct STOItem
* Item in a store, together with available amount etc.
*/
-struct STOItem {
+struct GEM_EXPORT STOItem {
ieResRef ItemResRef;
ieWord PurchasedAmount;
ieWord Usages[CHARGE_COUNTERS];
@@ -79,6 +79,8 @@ struct STOItem {
Trigger *trigger;
//ieDword TriggerRef; use infinitesupply
char unknown2[56];
+
+ ~STOItem();
};
View
1 gemrb/plugins/GUIScript/GUIScript.cpp
@@ -6337,6 +6337,7 @@ static PyObject* GemRB_ChangeStoreItem(PyObject * /*self*/, PyObject* args)
si->Flags &= ~IE_INV_ITEM_SELECTED;
} else {
store->RemoveItem( Slot );
+ delete si;
}
//keep encumbrance labels up to date
actor->CalculateSpeed(false);

0 comments on commit 73760ee

Please sign in to comment.