From c3bec911baf74863ca137cee2f52c27878c94441 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sat, 31 Aug 2019 17:10:51 +0200 Subject: [PATCH] Require bytes greater 0 --- .../main/java/org/jivesoftware/smackx/avatar/MetadataInfo.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/avatar/MetadataInfo.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/avatar/MetadataInfo.java index 0144f22f2..8972ee069 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/avatar/MetadataInfo.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/avatar/MetadataInfo.java @@ -55,6 +55,9 @@ public class MetadataInfo { public MetadataInfo(String id, URL url, long bytes, String type, int pixelsHeight, int pixelsWidth) { this.id = StringUtils.requireNotNullNorEmpty(id, "ID is required."); this.url = url; + if (bytes <= 0) { + throw new IllegalArgumentException("Number of bytes MUST be greater than 0."); + } this.bytes = UInt32.from(bytes); this.type = StringUtils.requireNotNullNorEmpty(type, "Content Type is required."); if (pixelsHeight < 0 || pixelsHeight > MAX_HEIGHT) {