$ git clone http://tcclient.ion.nu/tc_client.git
commit b1c6d578f89ba866d361a43e021950d89308d2a6
Author: Alicia <...>
Date:   Wed Jul 8 12:43:34 2015 +0200

    If an RTMP chunk already has a buffer allocated when a packet sets the length, free it and start over.

diff --git a/ChangeLog b/ChangeLog
index cd85e45..001b959 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 0.35:
 Adjusted for tinychat authentication changes (both for joining the channel and to use moderator accounts)
 Send account username in AMF0 "connect" command at startup regardless of whether we are modded or not, as is now required for non-mod accounts (contributed by Jade)
+If an RTMP chunk already has a buffer allocated when a packet sets the length, free it and start over.
 irchack: added a check for whether tc_client is installed or should be run from the source directory (should have been added along with the 'install' target)
 0.34:
 Fixed memory alignment in rtmp/amf code (for CPU architectures that are picky about it)
diff --git a/rtmp.c b/rtmp.c
index 281c74d..01b2e31 100644
--- a/rtmp.c
+++ b/rtmp.c
@@ -103,6 +103,11 @@ char rtmp_get(int sock, struct rtmp* rtmp)
       x=0;
       fullread(sock, ((void*)&x)+1, 3);
       chunk->length=be32(x);
+      if(chunk->buf) // Setting length of a chunk that is already partially received = start over
+      {
+        free(chunk->buf);
+        chunk->buf=0;
+      }
       // Type
       fullread(sock, &chunk->type, sizeof(chunk->type));
       if(fmt<1)