Dear list,<br><br>I have come to the habit of running my small programs through valgrind. One error being reported comes from enet.<br><br>This is the valgrind output:<br><br>==18627== Syscall param socketcall.sendmsg(msg.msg_iov[i]) points to uninitialised byte(s)<br>
==18627==    at 0x56816B0: __sendmsg_nocancel (in /lib64/<a href="http://libc-2.14.1.so">libc-2.14.1.so</a>)<br>==18627==    by 0x40D5C5: enet_socket_send (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>
==18627==    by 0x40CBFF: enet_protocol_send_outgoing_commands (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>==18627==    by 0x40CEB6: enet_host_service (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>
==18627==    by 0x4045E4: main (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>==18627==  Address 0x593614c is 156 bytes inside a block of size 10,976 alloc'd<br>==18627==    at 0x4C297CD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)<br>
==18627==    by 0x40D8B7: enet_malloc (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>==18627==    by 0x405C2D: enet_host_create (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>==18627==    by 0x405190: enet::Client::Client(std::string const&, unsigned short, double, unsigned long, unsigned int, unsigned int) (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>
==18627==    by 0x40455E: main (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>==18627==  Uninitialised value was created by a heap allocation<br>==18627==    at 0x4C297CD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)<br>
==18627==    by 0x40D8B7: enet_malloc (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>==18627==    by 0x405C2D: enet_host_create (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>==18627==    by 0x405190: enet::Client::Client(std::string const&, unsigned short, double, unsigned long, unsigned int, unsigned int) (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br>
==18627==    by 0x40455E: main (in /windows/Xchange/fts/scm/git/fts/gamedbg/build-d/fts-gamedbg)<br><br>I have looked into it for a little time and am now pretty confident it's not because of an usage error I made. My code is pretty simple and based on the tutorial. Applying the following patch fixes it for me:<br>
<br>--- host.c.orig    2011-12-08 12:25:44.187125000 +0100<br>+++ host.c    2011-12-08 12:23:43.661363000 +0100<br>@@ -38,6 +38,7 @@<br>     host = (ENetHost *) enet_malloc (sizeof (ENetHost));<br>     if (host == NULL)<br>
       return NULL;<br>+    memset (host, 0, sizeof (ENetHost));<br> <br>     host -> peers = (ENetPeer *) enet_malloc (peerCount * sizeof (ENetPeer));<br>     if (host -> peers == NULL)<br><br>I also attached the patch as a file to this email.<br>
<br>-- <br>Kind regards, Lucas<br><a href="http://arkana-fts.org" target="_blank">http://arkana-fts.org</a><br>