Skip to content

Commit

Permalink
fix nil pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
cfi2017 committed Apr 9, 2020
1 parent 8e06fc3 commit b5cdc97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/server/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func getCharacter(c *gin.Context) {

// workaround for invalid json parsing values
for _, d := range char.GbxZoneMapFodSaveGameData.LevelData {
if *d.DiscoveryPercentage > math.MaxFloat32 {
if d.DiscoveryPercentage != nil && *d.DiscoveryPercentage > math.MaxFloat32 {
*d.DiscoveryPercentage = -1
}
}
Expand All @@ -77,7 +77,7 @@ func updateCharacter(c *gin.Context) {
}
// workaround for invalid json parsing values
for _, d := range d.Character.GbxZoneMapFodSaveGameData.LevelData {
if *d.DiscoveryPercentage == -1 {
if d.DiscoveryPercentage != nil && *d.DiscoveryPercentage == -1 {
*d.DiscoveryPercentage = math.Float32frombits(0x7F800000) // inf
}
}
Expand Down

0 comments on commit b5cdc97

Please sign in to comment.