Packet streams: fix memory leak on dlist allocation failure.
authorKp <kp@valhallalegends.com>
Sun, 1 Jun 2008 17:25:50 +0000 (12:25 -0500)
committerKp <kp@valhallalegends.com>
Mon, 1 Sep 2008 20:13:56 +0000 (15:13 -0500)
If silc_dlist_init fails to allocate a SilcDList for stream->process,
then silc_packet_stream_link_va leaks the newly allocated
SilcPacketProcess.  Fix that by calling silc_free(p) on the error path.

lib/silccore/silcpacket.c

index d0445019769aa2f48a1b5d49849bc97852bb711d..df195f678075c20fb495b276977965221cebfbd0 100644 (file)
@@ -1030,6 +1030,7 @@ static SilcBool silc_packet_stream_link_va(SilcPacketStream stream,
     stream->process = silc_dlist_init();
     if (!stream->process) {
       silc_mutex_unlock(stream->lock);
     stream->process = silc_dlist_init();
     if (!stream->process) {
       silc_mutex_unlock(stream->lock);
+      silc_free(p);
       return FALSE;
     }
   }
       return FALSE;
     }
   }