OSDN Git Service

VPP: Check the VPP pipeline_parameter to avoid NULL pointer
authorZhao Yakui <yakui.zhao@intel.com>
Wed, 10 Aug 2016 04:30:12 +0000 (12:30 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Mon, 22 Aug 2016 04:08:56 +0000 (12:08 +0800)
This is to fix the crash issue caused by the commit
51ad826fcc0d2512f7ef74e807e4b8526663fc28.

Reported-by: Xu,Guangxin <guangxin.xu@itnel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit 4f8d4b211b4f90ef26c356b8028c5435cd685952)

src/gen75_vpp_vebox.c

index 566f337..2bc5cf9 100644 (file)
@@ -1379,10 +1379,29 @@ int hsw_veb_pre_format_convert(VADriverContextP ctx,
 
     proc_ctx->format_convert_flags = 0;
 
-    proc_ctx->width_input   = proc_ctx->pipeline_param->surface_region->width;
-    proc_ctx->height_input  = proc_ctx->pipeline_param->surface_region->height;
-    proc_ctx->width_output  = proc_ctx->pipeline_param->output_region->width;
-    proc_ctx->height_output = proc_ctx->pipeline_param->output_region->height;
+    if ((obj_surf_input == NULL) &&
+        (proc_ctx->pipeline_param->surface_region == NULL))
+        assert(0);
+
+    if ((obj_surf_output == NULL) &&
+        (proc_ctx->pipeline_param->output_region == NULL))
+        assert(0);
+
+    if (proc_ctx->pipeline_param->surface_region) {
+        proc_ctx->width_input   = proc_ctx->pipeline_param->surface_region->width;
+        proc_ctx->height_input  = proc_ctx->pipeline_param->surface_region->height;
+    } else {
+        proc_ctx->width_input   = obj_surf_input->orig_width;
+        proc_ctx->height_input  = obj_surf_input->orig_height;
+    }
+
+    if (proc_ctx->pipeline_param->output_region) {
+        proc_ctx->width_output  = proc_ctx->pipeline_param->output_region->width;
+        proc_ctx->height_output = proc_ctx->pipeline_param->output_region->height;
+    } else {
+        proc_ctx->width_output  = obj_surf_output->orig_width;
+        proc_ctx->height_output = obj_surf_output->orig_height;
+    }
 
     /* only partial frame is not supported to be processed */
     /*