Avoid crashes due to setting value outside of range

Stephen Paul Weber created

In case of bad value

Change summary

src/main/java/eu/siacs/conversations/entities/Conversation.java | 7 ++
1 file changed, 6 insertions(+), 1 deletion(-)

Detailed changes

src/main/java/eu/siacs/conversations/entities/Conversation.java 🔗

@@ -2545,7 +2545,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
                     }
 
                     if (field.getValues().size() > 0) {
-                        binding.slider.setValue(Float.valueOf(field.getValue().getContent()));
+                        final var val = Float.valueOf(field.getValue().getContent());
+                        if ((min == null || val >= min) && (max == null || val <= max)) {
+                            binding.slider.setValue(Float.valueOf(field.getValue().getContent()));
+                        } else {
+                            binding.slider.setValue(min == null ? Float.MIN_VALUE : min);
+                        }
                     } else {
                         binding.slider.setValue(min == null ? Float.MIN_VALUE : min);
                     }