Commit d7d5c5a
committed
Fix correctness, safety, and performance issues in video frame handling
Addresses three critical issues identified in code review:
1. Performance: Extract duplicate stride calculation logic into a shared
calculateAlignedStride helper function to eliminate code duplication
between NewFramebuffer and resizeMat
2. Memory Safety: Add buffer bounds validation in avcodec_decoder_convert_frame
to prevent potential buffer overruns when stride exceeds allocated space
3. Const Correctness: Remove const qualifier from avcodec_decoder_decode as
it modifies decoder state during multi-frame extraction1 parent 2524f7d commit d7d5c5a
3 files changed
+25
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
499 | 507 | | |
500 | 508 | | |
501 | 509 | | |
| |||
582 | 590 | | |
583 | 591 | | |
584 | 592 | | |
585 | | - | |
| 593 | + | |
586 | 594 | | |
587 | 595 | | |
588 | 596 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
200 | 213 | | |
201 | 214 | | |
202 | 215 | | |
| |||
209 | 222 | | |
210 | 223 | | |
211 | 224 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 225 | + | |
219 | 226 | | |
220 | 227 | | |
221 | 228 | | |
| |||
268 | 275 | | |
269 | 276 | | |
270 | 277 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 278 | + | |
278 | 279 | | |
279 | 280 | | |
280 | 281 | | |
| |||
0 commit comments