[rtmpdump] r485 - trunk/librtmp/rtmp.c
hyc
subversion at mplayerhq.hu
Wed May 26 17:16:26 CEST 2010
Author: hyc
Date: Wed May 26 17:16:25 2010
New Revision: 485
Log:
Read buffer fixes: We overallocated the buf by 4 bytes, but the result
may not have needed the extra space. Also, don't return without reading
at least one packet. (Alternative: return early, but set EAGAIN...)
Modified:
trunk/librtmp/rtmp.c
Modified: trunk/librtmp/rtmp.c
==============================================================================
--- trunk/librtmp/rtmp.c Mon May 24 21:43:48 2010 (r484)
+++ trunk/librtmp/rtmp.c Wed May 26 17:16:25 2010 (r485)
@@ -4052,9 +4052,10 @@ Read_1_Packet(RTMP *r, char *buf, unsign
if (recopy)
{
- memcpy(buf, r->m_read.buf, buflen);
- r->m_read.bufpos = r->m_read.buf + buflen;
- r->m_read.buflen = ret - buflen;
+ len = ret > buflen ? buflen : ret;
+ memcpy(buf, r->m_read.buf, len);
+ r->m_read.bufpos = r->m_read.buf + len;
+ r->m_read.buflen = ret - len;
}
return ret;
}
@@ -4162,11 +4163,13 @@ fail:
size -= nRead;
}
- if (size > 0 && (nRead = Read_1_Packet(r, buf, size)) >= 0)
+ while (size > 0 && (nRead = Read_1_Packet(r, buf, size)) >= 0)
{
+ if (!nRead) continue;
buf += nRead;
total += nRead;
size -= nRead;
+ break;
}
if (nRead < 0)
r->m_read.status = nRead;
More information about the rtmpdump
mailing list