Mojira Archive
MC-254774

Crash when a villager with a gossip of value 0 shares gossips

Steps to Reproduce
Execute the following command several times during the daytime: /summon minecraft:villager ~ ~ ~ {Gossips: [{Target: [I; 438831016, 1755662668, -1977558996, -1156852131], Type: "trading", Value: 0}]}

Observed Behavior
Crash occurs

Code analysis
Yarn 1.19.1

In VillagerGossips#pickGossips the nextInt method is called with the sum of the absolute value of all gossip values of a villager. If a villager has a gossip of value 0 only, the sum is 0, causing the crash since nextInt expects a positive integer. There should be an early-return in case the sum is 0. This does not affect villagers without gossips because of the early-return a few lines above, which means this cannot be triggered in survival since no action produces a gossip of value 0.

Fixed

apple502j

[Mojang] Maxime Lebrot

2022-07-30, 08:43 PM

2022-08-30, 12:24 PM

2022-08-30, 12:24 PM

1

3

Confirmed

Important

Crash

1.19.1, 1.19.2

22w42a