Fix the segfault while encoding multiple slice per frame.
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Wed, 28 May 2014 21:02:41 +0000 (15:02 -0600)
committerXiang, Haihao <haihao.xiang@intel.com>
Mon, 16 Jun 2014 03:53:36 +0000 (11:53 +0800)
Zero initialize the packed raw data index array and
packed slice header index array during each preallocation.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
Reviewed-by: Zhao, Yakui <yakui.zhao@intel.com>
(cherry picked from commit fbbe401aa28a0b3859d587ef08f0df15a2f7c8f2)

src/i965_drv_video.c

index 82a4e69..68a6052 100755 (executable)
@@ -2489,6 +2489,7 @@ i965_encoder_render_picture(VADriverContextP ctx,
                  * the packed data index/count for the slice
                  */
                 if (encode->max_slice_params_ext > encode->slice_num) {
+                    int slice_num = encode->slice_num;
                     encode->slice_num = encode->max_slice_params_ext;
                     encode->slice_rawdata_index = realloc(encode->slice_rawdata_index,
                                                           encode->slice_num * sizeof(int));
@@ -2496,6 +2497,12 @@ i965_encoder_render_picture(VADriverContextP ctx,
                                                           encode->slice_num * sizeof(int));
                     encode->slice_header_index = realloc(encode->slice_header_index,
                                                           encode->slice_num * sizeof(int));
+                    memset(encode->slice_rawdata_index + slice_num, 0,
+                        sizeof(int) * NUM_SLICES);
+                    memset(encode->slice_rawdata_count + slice_num, 0,
+                        sizeof(int) * NUM_SLICES);
+                    memset(encode->slice_header_index + slice_num, 0,
+                        sizeof(int) * NUM_SLICES);
                     if ((encode->slice_rawdata_index == NULL) ||
                         (encode->slice_header_index == NULL)  ||
                         (encode->slice_rawdata_count == NULL)) {