Skip to content

Commit

Permalink
Set player->history NULL after saving it to birther
Browse files Browse the repository at this point in the history
When Player rolls a new character, the previous character's history is saved
but then freed in do_cmd_roll_stats(), making the saved history a dangling
pointer. If player goes back to the previous character and then reroll,
the game tries to free already free data.
  • Loading branch information
kusunosetoru committed Mar 2, 2019
1 parent 25a322e commit a5d23dc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/player-birth.c
Expand Up @@ -159,6 +159,7 @@ static void save_roller_data(birther *tosave)
tosave->stat[i] = player->stat_birth[i];

tosave->history = player->history;
player->history = NULL;
my_strcpy(tosave->name, player->full_name, sizeof(tosave->name));
}

Expand Down

0 comments on commit a5d23dc

Please sign in to comment.