Fix buffer size checks when appending using SNPRINTF/WelsSnprintf
Checking iBufferLeft > iBufferUsed does not make sense, since this would stop writing into the buffer alredy after the buffer is half full, when there is less space left than has been used. The right check is iBufferLeft > 0.
This commit is contained in:
parent
98bad4f2b3
commit
a344d100ae
@ -110,23 +110,23 @@ CWelsDecoder::CWelsDecoder (void_t)
|
||||
iBufUsedSize += WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);
|
||||
|
||||
iBufLeft -= iBufUsed;
|
||||
if (iBufLeft > iBufUsed) {
|
||||
if (iBufLeft > 0) {
|
||||
iBufUsed += WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
|
||||
iBufLeft -= iBufUsed;
|
||||
}
|
||||
|
||||
iBufLeftSize -= iBufUsedSize;
|
||||
if (iBufLeftSize > iBufUsedSize) {
|
||||
if (iBufLeftSize > 0) {
|
||||
iBufUsedSize += WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
|
||||
iBufLeftSize -= iBufUsedSize;
|
||||
}
|
||||
|
||||
if (iBufLeft > iBufUsed) {
|
||||
if (iBufLeft > 0) {
|
||||
iBufUsed += WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond (&sCurTime));
|
||||
iBufLeft -= iBufUsed;
|
||||
}
|
||||
|
||||
if (iBufLeftSize > iBufUsedSize) {
|
||||
if (iBufLeftSize > 0) {
|
||||
iBufUsedSize += WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len",
|
||||
WelsGetMillsecond (&sCurTime));
|
||||
iBufLeftSize -= iBufUsedSize;
|
||||
|
@ -132,7 +132,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder()
|
||||
|
||||
|
||||
iBufferLeft -= iBufferUsed;
|
||||
if (iBufferLeft > iBufferUsed) {
|
||||
if (iBufferLeft > 0) {
|
||||
#if defined(_GNUC__)
|
||||
iBufferUsed += strftime (&strStreamFileName[iBufferUsed], iBufferLeft, "%y%m%d%H%M%S", tTimeNow);
|
||||
#else
|
||||
@ -150,7 +150,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder()
|
||||
}
|
||||
|
||||
iBufferLeftSize -= iBufferUsedSize;
|
||||
if (iBufferLeftSize > iBufferUsedSize) {
|
||||
if (iBufferLeftSize > 0) {
|
||||
#if defined(_GNUC__)
|
||||
iBufferUsedSize += strftime (&strLenFileName[iBufferUsedSize], iBufferLeftSize, "%y%m%d%H%M%S", tTimeNow);
|
||||
#else
|
||||
@ -167,7 +167,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder()
|
||||
iBufferLeftSize -= iBufferUsedSize;
|
||||
}
|
||||
|
||||
if (iBufferLeft > iBufferUsed) {
|
||||
if (iBufferLeft > 0) {
|
||||
#ifdef _WIN32
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER>=1500
|
||||
@ -182,7 +182,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder()
|
||||
iBufferLeft -= iBufferUsed;
|
||||
}
|
||||
|
||||
if (iBufferLeftSize > iBufferUsedSize) {
|
||||
if (iBufferLeftSize > 0) {
|
||||
#ifdef _WIN32
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER>=1500
|
||||
|
Loading…
x
Reference in New Issue
Block a user