防止可能内存越界的问题

This commit is contained in:
xiongziliang 2021-01-31 18:25:12 +08:00
parent 4c1f7babad
commit 837597e162

View File

@ -35,8 +35,8 @@ bool getAVCInfo(const string &strSps, int &iVideoWidth, int &iVideoHeight, float
return getAVCInfo(strSps.data(), strSps.size(), iVideoWidth, iVideoHeight, iVideoFps);
}
static const char *memfind(const char *buf, size_t len, const char *subbuf, size_t sublen) {
for (ssize_t i = 0; i < (ssize_t)(len - sublen); ++i) {
static const char *memfind(const char *buf, ssize_t len, const char *subbuf, ssize_t sublen) {
for (auto i = 0; i < len - sublen; ++i) {
if (memcmp(buf + i, subbuf, sublen) == 0) {
return buf + i;
}