[rtmpdump] patch: gcc -Wshadow

Peter Miller pmiller at opensource.org.au
Sat Apr 9 02:57:09 CEST 2011


This patch adds the use of gcc -Wshadow, which issues warnings when a
symbol declaration 'shadows' an earlier declaration.  This can expose
hard-to-find bugs when you think you are using a variable from the outer
scope, when in fact you are using the variable from the inner scope, and
your changes to the 'outer' variable are disappearing.  This is even
more important when developers other than the original author are
reading the code.


-- 
Regards
Peter Miller <pmiller at opensource.org.au>
/\/\*        http://miller.emu.id.au/pmiller/

PGP public key ID: 1024D/D0EDB64D
fingerprint = AD0A C5DF C426 4F03 5D53  2BDB 18D8 A4E2 D0ED B64D
See http://www.keyserver.net or any PGP keyserver for public key.

"A mathematician is a machine for turning coffee into
theorems." -- Alfred Renyi
-------------- next part --------------
MIME-Version: 1.0
Content-Type: application/aegis-patch
Subject: rtmpdump.2.3 - gcc -Wshadow
Content-Name: rtmpdump.2.3.C025.patch
Content-Disposition: attachment; filename=rtmpdump.2.3.C025.patch
X-Aegis-Project-Name: rtmpdump.2.3
X-Aegis-Change-Number: 25

#	
#	This change set adds the use of -Wshadow, which issues warnings when a
#	symbol declaration 'shadows' an earlier declaration.  This can expose
#	hard-to-find bugs when you think you are using a variable from the
#	outer scope, when in fact you are using the variable from the inner
#	scope, and your changes to the 'outer' variable are disappearing.
#	This is even more important when developers other than the original
#	author are reading the code.
#	
# Aegis-Change-Set-Begin
# QlpoMzFBWSZTWQh5YccAAYdfgAAQUIf/6gACBIq/79/qUANe7HG7mqYMoaJomEGhqp7aKn4n
# qk/U9SfpQ9QwIqfpkU9oamnqgAAAAAEoQUeCps1E00xoQAMg0MBoyGgwgGgGmgABJEBCU9lT
# 21GVG1HqeUbSeptJmozJaWQvCBgE8AHQXkkI5enLnB+YDxcZxBUBUDmlh3k7CsfrofFqdCEY
# NRyvUYFWLvdkBawswwGsgOk83eXG5LFOJ5XHBYjFR+UrvwADaIfCDnKf/uGYMyECBRyUPkgG
# Cp3Nq+vZLuem9LSXVRiX9Tsr7ORWItfWZ3xWImqlU+8vf32nYhmBMPrXd4zZlKaNxHgnkmZU
# oPWIZYSW/Q5iM8ZoE5yHK9WMHxV0n3RatYKDFGVq2i5pG0ASVpM6sSIJVcggpIp3IVusKkj6
# VGaNAGZnWUsitHEgRQjo6MDtFXtFAeVgCBvE1nndhJcKxnExpiwrqwzSZ9UCP2wys3HqgPAZ
# XIHESQ/d3ah3CenF6t2dB96meuZlM2S13aRtRy5Pv8EvBp4kAl1v7K5/JAU/wkRDN+71GJum
# EWBwVor7Md7DCt4pKS8UE2Ltnkz0+IMPYvN2oETsv8EWCAxG/CmhTzhSuN+Ubu0IDcDGRzoN
# vCwhAQ4FDl4VvN/jKDUqXHHDRHP8d8Rlso4va0gHVGWXVKUIA9NSA4ZmoezmUZ7MLKBnJGSv
# vt1ceCKgZTQNkbVu7KdjtfSngQ7epfJZEo9A3HRZjDTK8WMKxBLcj1zlrfzxSDeFptrw1tqV
# fh3pvQ/1AepANgNyA3Ic8kAoI1W3fDUtlCHWCWoMzeE0+S6g3TAQ8NUD6pGHNukJ3Ual+WFx
# BClIiRab50yddGc8lvSOAX8FQ7VQQ0fARjZhXjE1UExMi47QIXWQPJtrIcaLDzHobeaDDGpM
# SkZm6lMRsgzQP7X2VEtxVnZuvzcW0jbciRsggciy2cdYK1pwsNe2pjCXlQPoFy24hp0yOw3X
# QI3IDrLg/qa3PKwQNV5TVHOhsi5IbdakUxWdFHz3LMDQsLZqlEBqIEctTI+SWii66CG+Qj5I
# KVU4kIiKyWRJmN843siMg1QRiFRA/xdyRThQkAh5Ycc=
# Aegis-Change-Set-End
#
Index: Makefile
--- Makefile
+++ Makefile
@@ -21,7 +21,7 @@
 
 DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
 OPT=-O2
-CFLAGS=-Wall -Wextra -Werror $(XCFLAGS) $(INC) $(DEF) $(OPT)
+CFLAGS=-Wall -Wextra -Wshadow -Werror $(XCFLAGS) $(INC) $(DEF) $(OPT)
 LDFLAGS=-Wall $(XLDFLAGS)
 
 bindir=$(prefix)/bin
Index: librtmp/Makefile
--- librtmp/Makefile
+++ librtmp/Makefile
@@ -67,7 +67,7 @@
 
 DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
 OPT=-O2
-CFLAGS=-Wall -Wextra -Werror $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
+CFLAGS=-Wall -Wextra -Wshadow -Werror $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
 LDFLAGS=$(XLDFLAGS)
 
 
Index: librtmp/amf.c
--- librtmp/amf.c
+++ librtmp/amf.c
@@ -669,10 +669,10 @@
       }
     case AMF_OBJECT:
       {
-	int nRes = AMF_Decode(&prop->p_vu.p_object, pBuffer, nSize, TRUE);
-	if (nRes == -1)
+	int decRes = AMF_Decode(&prop->p_vu.p_object, pBuffer, nSize, TRUE);
+	if (decRes == -1)
 	  return -1;
-	nSize -= nRes;
+	nSize -= decRes;
 	break;
       }
     case AMF_MOVIECLIP:
@@ -765,10 +765,10 @@
       }
     case AMF_AVMPLUS:
       {
-	int nRes = AMF3_Decode(&prop->p_vu.p_object, pBuffer, nSize, TRUE);
-	if (nRes == -1)
+	int decRes = AMF3_Decode(&prop->p_vu.p_object, pBuffer, nSize, TRUE);
+	if (decRes == -1)
 	  return -1;
-	nSize -= nRes;
+	nSize -= decRes;
 	prop->p_type = AMF_OBJECT;
 	break;
       }
@@ -1039,7 +1039,7 @@
 	    }
 	  if (cd.cd_dynamic)
 	    {
-	      int len = 0;
+	      int plen = 0;
 
 	      do
 		{
@@ -1049,9 +1049,9 @@
 		  pBuffer += nRes;
 		  nSize -= nRes;
 
-		  len = prop.p_name.av_len;
+		  plen = prop.p_name.av_len;
 		}
-	      while (len > 0);
+	      while (plen > 0);
 	    }
 	}
       RTMP_Log(RTMP_LOGDEBUG, "class object!");
Index: librtmp/hashswf.c
--- librtmp/hashswf.c
+++ librtmp/hashswf.c
@@ -359,7 +359,7 @@
 static time_t
 make_unix_time(char *s)
 {
-  struct tm time;
+  struct tm when;
   int i, ysub = 1900, fmt = 0;
   char *month;
   char *n;
@@ -375,18 +375,18 @@
     if (*n == '-' || *n == ':')
       *n = ' ';
 
-  time.tm_mon = 0;
+  when.tm_mon = 0;
   n = strchr(s, ' ');
   if (fmt)
     {
       /* Day, DD-MMM-YYYY HH:MM:SS GMT */
-      time.tm_mday = strtol(n + 1, &n, 0);
+      when.tm_mday = strtol(n + 1, &n, 0);
       month = n + 1;
       n = strchr(month, ' ');
-      time.tm_year = strtol(n + 1, &n, 0);
-      time.tm_hour = strtol(n + 1, &n, 0);
-      time.tm_min = strtol(n + 1, &n, 0);
-      time.tm_sec = strtol(n + 1, NULL, 0);
+      when.tm_year = strtol(n + 1, &n, 0);
+      when.tm_hour = strtol(n + 1, &n, 0);
+      when.tm_min = strtol(n + 1, &n, 0);
+      when.tm_sec = strtol(n + 1, NULL, 0);
     }
   else
     {
@@ -396,22 +396,22 @@
       n = strchr(month, ' ');
       while (isspace(*n))
 	n++;
-      time.tm_mday = strtol(n, &n, 0);
-      time.tm_hour = strtol(n + 1, &n, 0);
-      time.tm_min = strtol(n + 1, &n, 0);
-      time.tm_sec = strtol(n + 1, &n, 0);
-      time.tm_year = strtol(n + 1, NULL, 0);
+      when.tm_mday = strtol(n, &n, 0);
+      when.tm_hour = strtol(n + 1, &n, 0);
+      when.tm_min = strtol(n + 1, &n, 0);
+      when.tm_sec = strtol(n + 1, &n, 0);
+      when.tm_year = strtol(n + 1, NULL, 0);
     }
-  if (time.tm_year > 100)
-    time.tm_year -= ysub;
+  if (when.tm_year > 100)
+    when.tm_year -= ysub;
 
   for (i = 0; i < 12; i++)
     if (!strncasecmp(month, monthtab[i], 3))
       {
-	time.tm_mon = i;
+	when.tm_mon = i;
 	break;
       }
-  time.tm_isdst = 0;		/* daylight saving is never in effect in GMT */
+  when.tm_isdst = 0;		/* daylight saving is never in effect in GMT */
 
   /* this is normally the value of extern int timezone, but some
    * braindead C libraries don't provide it.
@@ -424,8 +424,8 @@
       tzoff = (12 - tc->tm_hour) * 3600 + tc->tm_min * 60 + tc->tm_sec;
       tzchecked = 1;
     }
-  res = mktime(&time);
-  /* Unfortunately, mktime() assumes the input is in local time,
+  res = mktime(&when);
+  /* Unfortunately, mktime() assumes the input is in local when,
    * not GMT, so we have to correct it here.
    */
   if (res != -1)
@@ -548,10 +548,11 @@
 		}
 	      else if (!strncmp(buf, "hash: ", 6))
 		{
-		  unsigned char *ptr = hash, *in = (unsigned char *)buf + 6;
-		  int l = strlen((char *)in) - 1;
+		  unsigned char *ptr = hash;
+                  unsigned char *inp = (unsigned char *)buf + 6;
+		  int l = strlen((char *)inp) - 1;
 		  for (i = 0; i < l; i += 2)
-		    *ptr++ = (HEX2BIN(in[i]) << 4) | HEX2BIN(in[i + 1]);
+		    *ptr++ = (HEX2BIN(inp[i]) << 4) | HEX2BIN(inp[i + 1]);
 		  got++;
 		}
 	      else if (!strncmp(buf, "date: ", 6))
Index: librtmp/rtmp.c
--- librtmp/rtmp.c
+++ librtmp/rtmp.c
@@ -783,14 +783,14 @@
   service->sin_addr.s_addr = inet_addr(hostname);
   if (service->sin_addr.s_addr == INADDR_NONE)
     {
-      struct hostent *host = gethostbyname(hostname);
-      if (host == NULL || host->h_addr == NULL)
+      struct hostent *hep = gethostbyname(hostname);
+      if (hep == NULL || hep->h_addr == NULL)
 	{
 	  RTMP_Log(RTMP_LOGERROR, "Problem accessing the DNS. (addr: %s)", hostname);
 	  ret = FALSE;
 	  goto finish;
 	}
-      service->sin_addr = *(struct in_addr *)host->h_addr;
+      service->sin_addr = *(struct in_addr *)hep->h_addr;
     }
 
   service->sin_port = htons(port);
Index: rtmpdump.c
--- rtmpdump.c
+++ rtmpdump.c
@@ -132,7 +132,7 @@
 
 int
 OpenResumeFile(const char *flvFile,       /* file name [in] */
-               FILE **file,               /* opened file [out] */
+               FILE **out_file,           /* opened file [out] */
                off_t *size,               /* size of the file [out] */
                char **metaHeader,         /* meta data read from the file
                                            * [out] */
@@ -146,16 +146,16 @@
   *nMetaHeaderSize = 0;
   *size = 0;
 
-  *file = fopen(flvFile, "r+b");
-  if (!*file)
+  *out_file = fopen(flvFile, "r+b");
+  if (!*out_file)
     {
       /* RD_SUCCESS, because we go to fresh file mode instead of quiting */
       return RD_SUCCESS;
     }
 
-  fseek(*file, 0, SEEK_END);
-  *size = ftello(*file);
-  fseek(*file, 0, SEEK_SET);
+  fseek(*out_file, 0, SEEK_END);
+  *size = ftello(*out_file);
+  fseek(*out_file, 0, SEEK_SET);
 
   if (*size > 0)
     {
@@ -163,7 +163,7 @@
       uint32_t prevTagSize = 0;
 
       /* check we've got a valid FLV file to continue! */
-      if (fread(hbuf, 1, 13, *file) != 13)
+      if (fread(hbuf, 1, 13, *out_file) != 13)
 	{
 	  RTMP_Log(RTMP_LOGERROR, "Couldn't read FLV file header!");
 	  return RD_FAILED;
@@ -183,9 +183,9 @@
 	}
 
       uint32_t dataOffset = AMF_DecodeInt32(hbuf + 5);
-      fseek(*file, dataOffset, SEEK_SET);
+      fseek(*out_file, dataOffset, SEEK_SET);
 
-      if (fread(hbuf, 1, 4, *file) != 4)
+      if (fread(hbuf, 1, 4, *out_file) != 4)
 	{
 	  RTMP_Log(RTMP_LOGERROR, "Invalid FLV file: missing first prevTagSize!");
 	  return RD_FAILED;
@@ -204,8 +204,8 @@
 
       while (pos < *size - 4 && !bFoundMetaHeader)
 	{
-	  fseeko(*file, pos, SEEK_SET);
-	  if (fread(hbuf, 1, 4, *file) != 4)
+	  fseeko(*out_file, pos, SEEK_SET);
+	  if (fread(hbuf, 1, 4, *out_file) != 4)
 	    break;
 
 	  uint32_t dataSize = AMF_DecodeInt24(hbuf + 1);
@@ -223,8 +223,8 @@
 		    return RD_FAILED;
 		}
 
-	      fseeko(*file, pos + 11, SEEK_SET);
-	      if (fread(buffer, 1, dataSize, *file) != dataSize)
+	      fseeko(*out_file, pos + 11, SEEK_SET);
+	      if (fread(buffer, 1, dataSize, *out_file) != dataSize)
 		break;
 
 	      AMFObject metaObj;
@@ -274,7 +274,7 @@
 }
 
 int
-GetLastKeyframe(FILE *file,                  /* output file [in] */
+GetLastKeyframe(FILE *out_file,              /* output file [in] */
                 int nSkipKeyFrames,          /* max number of frames to skip
                                               * when searching for key frame
                                               * [in] */
@@ -292,11 +292,11 @@
   int bAudioOnly;
   off_t size;
 
-  fseek(file, 0, SEEK_END);
-  size = ftello(file);
+  fseek(out_file, 0, SEEK_END);
+  size = ftello(out_file);
 
-  fseek(file, 4, SEEK_SET);
-  if (fread(&dataType, sizeof(uint8_t), 1, file) != 1)
+  fseek(out_file, 4, SEEK_SET);
+  if (fread(&dataType, sizeof(uint8_t), 1, out_file) != 1)
     return RD_FAILED;
 
   bAudioOnly = (dataType & 0x4) && !(dataType & 0x1);
@@ -328,8 +328,8 @@
 	      "Unexpected start of file, error in tag sizes, couldn't arrive at prevTagSize=0");
 	  return RD_FAILED;
 	}
-      fseeko(file, size - tsize - 4, SEEK_SET);
-      xread = fread(buffer, 1, 4, file);
+      fseeko(out_file, size - tsize - 4, SEEK_SET);
+      xread = fread(buffer, 1, 4, out_file);
       if (xread != 4)
 	{
 	  RTMP_Log(RTMP_LOGERROR, "Couldn't read prevTagSize from file!");
@@ -357,8 +357,8 @@
       tsize += prevTagSize + 4;
 
       /* read header */
-      fseeko(file, size - tsize, SEEK_SET);
-      if (fread(buffer, 1, 12, file) != 12)
+      fseeko(out_file, size - tsize, SEEK_SET);
+      if (fread(buffer, 1, 12, out_file) != 12)
 	{
 	  RTMP_Log(RTMP_LOGERROR, "Couldn't read header!");
 	  return RD_FAILED;
@@ -398,8 +398,8 @@
   *nInitialFrameSize = prevTagSize - 11;
   *initialFrame = (char *) malloc(*nInitialFrameSize);
 
-  fseeko(file, size - tsize + 11, SEEK_SET);
-  if (fread(*initialFrame, 1, *nInitialFrameSize, file) != *nInitialFrameSize)
+  fseeko(out_file, size - tsize + 11, SEEK_SET);
+  if (fread(*initialFrame, 1, *nInitialFrameSize, out_file) != *nInitialFrameSize)
     {
       RTMP_Log(RTMP_LOGERROR, "Couldn't read last keyframe, aborting!");
       return RD_FAILED;
@@ -425,31 +425,33 @@
   RTMP_Log(RTMP_LOGDEBUG, "Last keyframe found at: %d ms, size: %d, type: %02X", *dSeek,
       *nInitialFrameSize, *initialFrameType);
 
-  /*
-     // now read the timestamp of the frame before the seekable keyframe:
-     fseeko(file, size-tsize-4, SEEK_SET);
-     if(fread(buffer, 1, 4, file) != 4) {
-     RTMP_Log(RTMP_LOGERROR, "Couldn't read prevTagSize from file!");
-     goto start;
-     }
-     uint32_t prevTagSize = RTMP_LIB::AMF_DecodeInt32(buffer);
-     fseeko(file, size-tsize-4-prevTagSize+4, SEEK_SET);
-     if(fread(buffer, 1, 4, file) != 4) {
-     RTMP_Log(RTMP_LOGERROR, "Couldn't read previous timestamp!");
-     goto start;
-     }
-     uint32_t timestamp = RTMP_LIB::AMF_DecodeInt24(buffer);
-     timestamp |= (buffer[3]<<24);
+#if 0
+   /* now read the timestamp of the frame before the seekable keyframe: */
+   fseeko(out_file, size-tsize-4, SEEK_SET);
+   if (fread(buffer, 1, 4, out_file) != 4)
+    {
+      RTMP_Log(RTMP_LOGERROR, "Couldn't read prevTagSize from file!");
+      goto start;
+    }
+   uint32_t prevTagSize = RTMP_LIB::AMF_DecodeInt32(buffer);
+   fseeko(out_file, size - tsize - 4 - prevTagSize + 4, SEEK_SET);
+   if (fread(buffer, 1, 4, out_file) != 4)
+    {
+      RTMP_Log(RTMP_LOGERROR, "Couldn't read previous timestamp!");
+      goto start;
+    }
+   uint32_t timestamp = RTMP_LIB::AMF_DecodeInt24(buffer);
+   timestamp |= (buffer[3]<<24);
 
-     RTMP_Log(RTMP_LOGDEBUG, "Previous timestamp: %d ms", timestamp);
-   */
+   RTMP_Log(RTMP_LOGDEBUG, "Previous timestamp: %d ms", timestamp);
+#endif
 
   if (*dSeek != 0)
     {
       /* seek to position after keyframe in our file (we will ignore the
        * keyframes resent by the server since they are sent a couple of
        * times and handling this would be a mess).  */
-      fseeko(file, size - tsize + prevTagSize + 4, SEEK_SET);
+      fseeko(out_file, size - tsize + prevTagSize + 4, SEEK_SET);
 
 #if 0
       /* make sure the WriteStream doesn't write headers and ignores all
@@ -464,7 +466,7 @@
 
 int
 Download(RTMP *rtmp,		/* connected RTMP object */
-	 FILE *file,
+	 FILE *out_file,
          uint32_t dSeek,
          uint32_t dStopOffset,
          double duration,
@@ -486,7 +488,7 @@
   int bufferSize = 64 * 1024;
   char *buffer = (char *) malloc(bufferSize);
   int nRead = 0;
-  off_t size = ftello(file);
+  off_t size = ftello(out_file);
   unsigned long lastPercent = 0;
   int status;
 
@@ -558,7 +560,7 @@
 #endif
       if (nRead > 0)
 	{
-	  if (fwrite(buffer, sizeof(unsigned char), nRead, file) !=
+	  if (fwrite(buffer, sizeof(unsigned char), nRead, out_file) !=
 	      (size_t) nRead)
 	    {
               int err = errno;
@@ -846,13 +848,13 @@
   RTMP_debuglevel = RTMP_LOGINFO;
 
   /* Check for --quiet option before printing any output */
-  int index = 0;
-  while (index < argc)
+  int arg_index = 0;
+  while (arg_index < argc)
     {
-      if (strcmp(argv[index], "--quiet") == 0
-	  || strcmp(argv[index], "-q") == 0)
+      if (strcmp(argv[arg_index], "--quiet") == 0
+	  || strcmp(argv[arg_index], "-q") == 0)
 	RTMP_debuglevel = RTMP_LOGCRIT;
-      index++;
+      arg_index++;
     }
 
   RTMP_LogPrintf("RTMPDump %s\n", RTMPDUMP_VERSION);
Index: rtmpgw.c
--- rtmpgw.c
+++ rtmpgw.c
@@ -423,9 +423,9 @@
 	  if (*ptr == '?')
 	    {
 	      ptr++;
-	      int len = strlen(ptr);
+	      int plen = strlen(ptr);
 
-	      while (len >= 2)
+	      while (plen >= 2)
 		{
 		  char ich = *ptr;
 		  ptr++;
@@ -433,12 +433,12 @@
 		    goto filenotfound;	/* long parameters not (yet) supported */
 
 		  ptr++;
-		  len -= 2;
+		  plen -= 2;
 
 		  /* get position of the next '&' */
 		  char *temp;
 
-		  unsigned int nArgLen = len;
+		  unsigned int nArgLen = plen;
 		  if ((temp = strstr(ptr, "&")) != 0)
 		    {
 		      nArgLen = temp - ptr;
@@ -458,7 +458,7 @@
 		      ich, arg);
 
 		  ptr += nArgLen + 1;
-		  len -= nArgLen + 1;
+		  plen -= nArgLen + 1;
 
 		  if (!ParseOption(ich, arg, &req))
 		    {
@@ -588,15 +588,15 @@
       double duration = 0.0;
 
       int nWritten = 0;
-      int nRead = 0;
+      int nRead2 = 0;
 
       do
 	{
-	  nRead = RTMP_Read(&rtmp, buffer, PACKET_SIZE);
+	  nRead2 = RTMP_Read(&rtmp, buffer, PACKET_SIZE);
 
-	  if (nRead > 0)
+	  if (nRead2 > 0)
 	    {
-	      if ((nWritten = send(sockfd, buffer, nRead, 0)) < 0)
+	      if ((nWritten = send(sockfd, buffer, nRead2, 0)) < 0)
 		{
 		  RTMP_Log(RTMP_LOGERROR, "%s, sending failed, error: %d", __FUNCTION__,
 		      GetSockError());
@@ -605,10 +605,11 @@
 		  goto cleanup;
 		}
 
-	      size += nRead;
+	      size += nRead2;
 
 #if 0
-	      RTMP_LogPrintf("write %dbytes (%.1f KB)\n", nRead, nRead/1024.0);
+	      RTMP_LogPrintf("write %dbytes (%.1f KB)\n", nRead2,
+                             nRead2 / 1024.0);
 #endif
 	      if (duration <= 0)
                 {
@@ -640,7 +641,7 @@
 	    }
 #endif
 	}
-      while (server->state == STREAMING_IN_PROGRESS && nRead > -1
+      while (server->state == STREAMING_IN_PROGRESS && nRead2 > -1
 	     && RTMP_IsConnected(&rtmp) && nWritten >= 0);
     }
 cleanup:
Index: rtmpsrv.c
--- rtmpsrv.c
+++ rtmpsrv.c
@@ -560,10 +560,11 @@
       /* Still have more parameters? Copy them */
       if (obj.o_num > 3)
 	{
-	  int i = obj.o_num - 3;
-	  r->Link.extras.o_num = i;
-	  r->Link.extras.o_props = malloc(i*sizeof(AMFObjectProperty));
-	  memcpy(r->Link.extras.o_props, obj.o_props+3, i*sizeof(AMFObjectProperty));
+	  int j = obj.o_num - 3;
+	  r->Link.extras.o_num = j;
+	  r->Link.extras.o_props = malloc(j * sizeof(AMFObjectProperty));
+	  memcpy(r->Link.extras.o_props, obj.o_props + 3,
+                 j * sizeof(AMFObjectProperty));
 	  obj.o_num = 3;
 	  server->arglen += countAMF(&r->Link.extras, &server->argc);
 	}
Index: rtmpsuck.c
--- rtmpsuck.c
+++ rtmpsuck.c
@@ -649,7 +649,7 @@
 	}
 
       memcpy(ptr, packetBody, nPacketLen);
-      unsigned int len = nPacketLen;
+      unsigned int len2 = nPacketLen;
 
       /* correct tagSize and obtain timestamp if we have an FLV stream */
       if (packet->m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
@@ -685,7 +685,7 @@
 		  prevTagSize = dataSize + 11;
 		  AMF_EncodeInt32(ptr + pos + 11 + dataSize, pend, prevTagSize);
 		  size += 4;
-		  len += 4;
+		  len2 += 4;
 		}
 	      else
 		{
@@ -718,7 +718,7 @@
 	      pos += prevTagSize + 4;	/* (11 + dataSize + 4) */
 	    }
 	}
-      ptr += len;
+      ptr += len2;
 
       if (packet->m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
 	{


More information about the rtmpdump mailing list