History

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.

Martin Storsjö committed 12 years ago

Commit a344d101 parent 98bad4f2 files · +8 −8Browse files

Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 2 files). Show all

Unified · Split

codec/encoder/plus/src/welsEncoderExt.cpp+4−4
@@ -132,7 +132,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 131 unmodified lines
132132
133133
134134 iBufferLeft -= iBufferUsed;
135− if (iBufferLeft > iBufferUsed) {
135+ if (iBufferLeft > 0) {
136136 #if defined(_GNUC__)
137137 iBufferUsed += strftime (&strStreamFileName[iBufferUsed], iBufferLeft, "%y%m%d%H%M%S", tTimeNow);
138138 #else
@@ -150,7 +150,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 11 unmodified lines
150150 }
151151
152152 iBufferLeftSize -= iBufferUsedSize;
153− if (iBufferLeftSize > iBufferUsedSize) {
153+ if (iBufferLeftSize > 0) {
154154 #if defined(_GNUC__)
155155 iBufferUsedSize += strftime (&strLenFileName[iBufferUsedSize], iBufferLeftSize, "%y%m%d%H%M%S", tTimeNow);
156156 #else
@@ -167,7 +167,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 10 unmodified lines
167167 iBufferLeftSize -= iBufferUsedSize;
168168 }
169169
170− if (iBufferLeft > iBufferUsed) {
170+ if (iBufferLeft > 0) {
171171 #ifdef _WIN32
172172 #if defined(_MSC_VER)
173173 #if _MSC_VER>=1500
@@ -182,7 +182,7 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 8 unmodified lines
182182 iBufferLeft -= iBufferUsed;
183183 }
184184
185− if (iBufferLeftSize > iBufferUsedSize) {
185+ if (iBufferLeftSize > 0) {
186186 #ifdef _WIN32
187187 #if defined(_MSC_VER)
188188 #if _MSC_VER>=1500

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t