summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-01-31 11:30:57 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-01-31 11:30:57 +0000
commit748d2dbd9c453603ebf8968c9a747372b530da33 (patch)
tree57dd28dd97c8a9e47775dc1edc33c298003bbf95
parent4ca48efa52ab65853138653b30903528139d4919 (diff)
downloadhercules-748d2dbd9c453603ebf8968c9a747372b530da33.tar.gz
hercules-748d2dbd9c453603ebf8968c9a747372b530da33.tar.bz2
hercules-748d2dbd9c453603ebf8968c9a747372b530da33.tar.xz
hercules-748d2dbd9c453603ebf8968c9a747372b530da33.zip
* Fixed faulty WFIFO reallocation causing memory exhaustion (bugreport:4737, since r1816, related r11503, r11571, r11886 and r12232).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14689 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/common/socket.c6
2 files changed, 5 insertions, 3 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index d540175ea..3aee07ed2 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -1,5 +1,7 @@
Date Added
+2011/01/31
+ * Fixed faulty WFIFO reallocation causing memory exhaustion (bugreport:4737, since r1816, related r11503, r11571, r11886 and r12232). [Ai4rei]
2011/01/30
* Fixed equipped items' bonus no longer working after log-in until next status recalc, due to missing pc_setequipindex which was previously called by pc_checkitem (bugreport:2604, since r14685). [Ai4rei]
2011/01/29
diff --git a/src/common/socket.c b/src/common/socket.c
index ff667cf2e..0111e9eed 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -584,7 +584,7 @@ int realloc_writefifo(int fd, size_t addition)
if( session[fd]->wdata_size + addition > session[fd]->max_wdata )
{ // grow rule; grow in multiples of WFIFO_SIZE
newsize = WFIFO_SIZE;
- while( session[fd]->wdata_size + addition > newsize ) newsize += newsize;
+ while( session[fd]->wdata_size + addition > newsize ) newsize += WFIFO_SIZE;
}
else
if( session[fd]->max_wdata >= (size_t)2*(session[fd]->flag.server?FIFOSIZE_SERVERLINK:WFIFO_SIZE)
@@ -667,9 +667,9 @@ int WFIFOSET(int fd, size_t len)
// always keep a WFIFO_SIZE reserve in the buffer
// For inter-server connections, let the reserve be 1/4th of the link size.
- newreserve = s->wdata_size + ( s->flag.server ? FIFOSIZE_SERVERLINK / 4 : WFIFO_SIZE);
+ newreserve = s->flag.server ? FIFOSIZE_SERVERLINK / 4 : WFIFO_SIZE;
- // readjust the buffer to the newly chosen size
+ // readjust the buffer to include the chosen reserve
realloc_writefifo(fd, newreserve);
#ifdef SEND_SHORTLIST