summaryrefslogtreecommitdiff
path: root/src/network/network_content.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-07-08 18:38:38 +0000
committerfrosch <frosch@openttd.org>2010-07-08 18:38:38 +0000
commit4ce5c6d93dea944df7de559ea62b625a3643ce52 (patch)
tree903161acc876495d4b95056597c139fb49b7f10e /src/network/network_content.cpp
parent02e4371ecb7c36d1889c3c9f8d1eb30c92da4ba3 (diff)
downloadopenttd-4ce5c6d93dea944df7de559ea62b625a3643ce52.tar.xz
(svn r20089) -Fix [FS#3932]: Access of already freed memory, esp. due to hidden destructor call from Swap().
Diffstat (limited to 'src/network/network_content.cpp')
-rw-r--r--src/network/network_content.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp
index f70f0e724..a7032a60f 100644
--- a/src/network/network_content.cpp
+++ b/src/network/network_content.cpp
@@ -135,15 +135,13 @@ DEF_CONTENT_RECEIVE_COMMAND(Client, PACKET_CONTENT_SERVER_INFO)
/*
* As ici might be selected by the content window we cannot delete that.
* However, we want to keep most of the values of ci, except the values
- * we (just) already preserved. As there are already allocated blobs of
- * memory and more may be added, we cannot simply copy ci to ici as that
- * might cause a leak of memory. As such we need to swap the data and
- * then delete the memory we allocated here.
+ * we (just) already preserved.
+ * So transfer data and ownership of allocated memory from ci to ici.
*/
- Swap(*ici, *ci);
+ ici->TransferFrom(ci);
delete ci;
- this->OnReceiveContentInfo(ci);
+ this->OnReceiveContentInfo(ici);
return true;
}
}