Skip to content

Commit b5cdc97

Browse files
committed
fix nil pointer dereference
1 parent 8e06fc3 commit b5cdc97

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/server/character.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func getCharacter(c *gin.Context) {
5151

5252
// workaround for invalid json parsing values
5353
for _, d := range char.GbxZoneMapFodSaveGameData.LevelData {
54-
if *d.DiscoveryPercentage > math.MaxFloat32 {
54+
if d.DiscoveryPercentage != nil && *d.DiscoveryPercentage > math.MaxFloat32 {
5555
*d.DiscoveryPercentage = -1
5656
}
5757
}
@@ -77,7 +77,7 @@ func updateCharacter(c *gin.Context) {
7777
}
7878
// workaround for invalid json parsing values
7979
for _, d := range d.Character.GbxZoneMapFodSaveGameData.LevelData {
80-
if *d.DiscoveryPercentage == -1 {
80+
if d.DiscoveryPercentage != nil && *d.DiscoveryPercentage == -1 {
8181
*d.DiscoveryPercentage = math.Float32frombits(0x7F800000) // inf
8282
}
8383
}

0 commit comments

Comments
 (0)