aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-12 12:13:39 -0800
committerAustin Hellyer <[email protected]>2016-11-12 12:13:39 -0800
commit9d086a5592f0ced7607e0ea58b09523bd501a722 (patch)
tree47c38d126fd877308f035a086b704b18b8a3cdb1 /src
parentAdd a check for message content length (diff)
downloadserenity-9d086a5592f0ced7607e0ea58b09523bd501a722.tar.xz
serenity-9d086a5592f0ced7607e0ea58b09523bd501a722.zip
Don't overflow on message length check
Diffstat (limited to 'src')
-rw-r--r--src/model/channel.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/model/channel.rs b/src/model/channel.rs
index cd2c099..7b55d5c 100644
--- a/src/model/channel.rs
+++ b/src/model/channel.rs
@@ -494,11 +494,11 @@ impl Message {
pub fn overflow_length(content: &str) -> Option<u64> {
// Check if the content is over the maximum number of unicode code
// points.
- let count = content.chars().count() as u64;
- let diff = count - constants::MESSAGE_CODE_LIMIT as u64;
+ let count = content.chars().count() as i64;
+ let diff = count - (constants::MESSAGE_CODE_LIMIT as i64);
if diff > 0 {
- Some(diff)
+ Some(diff as u64)
} else {
None
}