Skip to content

Commit

Permalink
Fix: heap-use-after-free in doforging. Fixes #416.
Browse files Browse the repository at this point in the history
Resulted from 01a17b1, where weights were recalculated after the forging materials were used up.
  • Loading branch information
elunna committed Jul 31, 2023
1 parent 0f63f23 commit a7ae5ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions hackem_changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

Version 1.2.1 (unreleased)

Fix: heap-use-after-free in doforging. Fixes #416.
Revert Und-Vam
Put trench coat with non-randomized cloaks.
Fix: Update MAGICTILENO.
Expand Down
12 changes: 6 additions & 6 deletions src/fountain.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,19 +807,19 @@ doforging(void)
if (obj2->otyp == recipe->typ2)
obj2->quan -= recipe->quan_typ2;

/* delete recipe objects if quantity reaches zero */
if (obj1->quan <= 0)
delobj(obj1);
if (obj2->quan <= 0)
delobj(obj2);

/* recalculate weight of the recipe objects if
using a stack */
if (obj1->quan > 0)
obj1->owt = weight(obj1);
if (obj2->quan > 0)
obj2->owt = weight(obj2);

/* delete recipe objects if quantity reaches zero */
if (obj1->quan <= 0)
delobj(obj1);
if (obj2->quan <= 0)
delobj(obj2);

/* forged object is created */
output = addinv(output);
/* prevent large stacks of ammo-type weapons from being
Expand Down

0 comments on commit a7ae5ae

Please sign in to comment.