Avoid crashes
This commit is contained in:
parent
82bc60d510
commit
b1b191a6e7
@ -79,8 +79,12 @@ public class MessageEntity implements BotApiObject {
|
|||||||
public void computeText(String message) {
|
public void computeText(String message) {
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
byte[] bytes = message.getBytes(StandardCharsets.UTF_16LE);
|
byte[] bytes = message.getBytes(StandardCharsets.UTF_16LE);
|
||||||
|
if (bytes.length >= offset && offset >= 0 && length >= 0) {
|
||||||
text = new String(Arrays.copyOfRange(bytes, offset, offset + length),
|
text = new String(Arrays.copyOfRange(bytes, offset, offset + length),
|
||||||
StandardCharsets.UTF_16LE);
|
StandardCharsets.UTF_16LE);
|
||||||
|
} else {
|
||||||
|
text = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user