summaryrefslogtreecommitdiff
path: root/src/net/manaserv/messagein.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-06-08 22:44:53 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-06-08 22:44:57 +0200
commit877842e413daf830114939dc6915d225c40197c3 (patch)
tree0081e5c574ae77fffe0f38a2cb1383eee8c48e64 /src/net/manaserv/messagein.h
parentf9cd8a5d6b4460ffcb945979d1e8cd8ebadc9b8d (diff)
downloadmana-877842e413daf830114939dc6915d225c40197c3.tar.gz
mana-877842e413daf830114939dc6915d225c40197c3.tar.bz2
mana-877842e413daf830114939dc6915d225c40197c3.tar.xz
mana-877842e413daf830114939dc6915d225c40197c3.zip
Fixed MessageIn::getUnreadLength
It should not return large numbers after reading past the end of a message. This can cause infinite loops in several places in the client when a message happened to be shorter than expected.
Diffstat (limited to 'src/net/manaserv/messagein.h')
-rw-r--r--src/net/manaserv/messagein.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/net/manaserv/messagein.h b/src/net/manaserv/messagein.h
index 89ae5ed8..1edc4fe7 100644
--- a/src/net/manaserv/messagein.h
+++ b/src/net/manaserv/messagein.h
@@ -52,7 +52,10 @@ class MessageIn
/**
* Returns the length of unread data.
*/
- unsigned int getUnreadLength() const { return mLength - mPos; }
+ unsigned int getUnreadLength() const
+ {
+ return (mPos < mLength) ? mLength - mPos : 0;
+ }
/**
* Reads an unsigned 8-bit integer from the message.