Skip to content

Commit

Permalink
Smithing: have known version in special_display() and artefact_display()
Browse files Browse the repository at this point in the history
When smithed object is accepted, copy the known version into dynamically allocated memory so that later cleanup does not try to deallocated statically allocated memory.  Resolves the crash reported on 2024/11/5 for #728 .
  • Loading branch information
backwardsEric authored and NickMcConnell committed Nov 6, 2024
1 parent 7be98fc commit 07aff7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/obj-smith.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,10 @@ static void create_smithing_item(struct object *obj, struct smithing_cost *cost)

/* Create the object */
object_copy(created, obj);
if (obj->known) {
created->known = object_new();
object_copy(created->known, obj->known);
}

/* Identify the object */
object_flavor_aware(player, created);
Expand Down
4 changes: 2 additions & 2 deletions src/ui-smith.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,9 @@ static void special_display(struct menu *menu, int oid, bool cursor, int row,
uint8_t attr = affordable_specials[oid] ? COLOUR_WHITE : COLOUR_SLATE;
if (cursor) {
create_special(smith_obj, choice[oid]);
know_smith_obj();
pval = pval_valid(smith_obj) ? smith_obj->pval : 0;
include_pval(smith_obj);
know_smith_obj();
show_smith_obj();
exclude_pval(smith_obj);
}
Expand Down Expand Up @@ -890,8 +890,8 @@ static void artefact_display(struct menu *menu, int oid, bool cursor, int row,
attr = smithing_art_cat_counts[oid] > 0 ?
(cursor ? COLOUR_L_BLUE : COLOUR_WHITE) : COLOUR_L_DARK;
if (cursor) {
include_pval(smith_obj);
know_smith_obj();
include_pval(smith_obj);
show_smith_obj();
exclude_pval(smith_obj);
}
Expand Down

0 comments on commit 07aff7f

Please sign in to comment.