Plug potential memleak
authorHoward Chu <hyc@highlandsun.com>
Sat, 23 Jul 2011 01:06:27 +0000 (18:06 -0700)
committerHoward Chu <hyc@highlandsun.com>
Sat, 23 Jul 2011 01:06:27 +0000 (18:06 -0700)
Reported by Reijo Tomperi <aggro80@users.sourceforge.net>

rtmpdump.c

index 89c053a..e506fa9 100644 (file)
@@ -444,7 +444,7 @@ Download(RTMP * rtmp,               // connected RTMP object
 {
   int32_t now, lastUpdate;
   int bufferSize = 64 * 1024;
-  char *buffer = (char *) malloc(bufferSize);
+  char *buffer;
   int nRead = 0;
   off_t size = ftello(file);
   unsigned long lastPercent = 0;
@@ -505,6 +505,8 @@ Download(RTMP * rtmp,               // connected RTMP object
   rtmp->m_read.nMetaHeaderSize = nMetaHeaderSize;
   rtmp->m_read.nInitialFrameSize = nInitialFrameSize;
 
+  buffer = (char *) malloc(bufferSize);
+
   now = RTMP_GetTime();
   lastUpdate = now - 1000;
   do