diff mbox

[FFmpeg-devel] mjpegenc_huffman: fix uninitialized variable usage

Message ID 20170208231922.43398-1-atomnuker@gmail.com
State New
Headers show

Commit Message

Rostislav Pehlivanov Feb. 8, 2017, 11:19 p.m. UTC
Happened when max_length == 0, in which case i wasn't set to 0 during
the first run. i is supposed to already be at the maximum size when the
max_length is 0.

Fixes CID1400146

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
---
 libavcodec/mjpegenc_huffman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Feb. 9, 2017, 12:20 a.m. UTC | #1
On Wed, Feb 08, 2017 at 11:19:22PM +0000, Rostislav Pehlivanov wrote:
> Happened when max_length == 0, in which case i wasn't set to 0 during
> the first run. i is supposed to already be at the maximum size when the
> max_length is 0.

when / for what is max_length = 0 used ?
maybe i misuderstand but doesnt max_length mean the longest code would
have 0 bits ?

[...]
diff mbox

Patch

diff --git a/libavcodec/mjpegenc_huffman.c b/libavcodec/mjpegenc_huffman.c
index a5d7d5365b..075473429c 100644
--- a/libavcodec/mjpegenc_huffman.c
+++ b/libavcodec/mjpegenc_huffman.c
@@ -81,7 +81,7 @@  void ff_mjpegenc_huffman_compute_bits(PTable *prob_table, HuffTable *distincts,
 {
     PackageMergerList list_a, list_b, *to = &list_a, *from = &list_b, *temp;
 
-    int times, i, j, k;
+    int times, i = size, j, k;
 
     int nbits[257] = {0};