[Libva] [PATCH V1][libva] fix check NULL issues reported by Klockwork

Chen, Peng C peng.c.chen at intel.com
Mon May 23 06:58:33 UTC 2016



-----Original Message-----
From: Yuan, Shengquan 
Sent: Monday, May 23, 2016 2:28 PM
To: Chen, Peng C <peng.c.chen at intel.com>; libva at lists.freedesktop.org
Subject: RE: [Libva] [PATCH V1][libva] fix check NULL issues reported by Klockwork

Also you previous patch adds a "buffer manager" (line 336~line 455) , and the only purpose is that you can find the context from va_TraceMapBuffer and va_TraceDestroyBuffer.  I am not sure if we can make it simpler by extending vaBufferInfo

VAStatus vaBufferInfo(
    VADisplay dpy,
    VAContextID context,        /* in */
    VABufferID buf_id,          /* in */
    VABufferType *type,         /* out */
    unsigned int *size,         /* out */
    unsigned int *num_elements  /* out */
    );
[peng]yes, it can be done by extending vaBufferInfo. But I prefer to keep the compatibility of this API.  

-----Original Message-----
From: Yuan, Shengquan 
Sent: Monday, May 23, 2016 1:52 PM
To: 'peng.chen' <peng.c.chen at intel.com>; libva at lists.freedesktop.org
Subject: RE: [Libva] [PATCH V1][libva] fix check NULL issues reported by Klockwork

Can you also add a space after "if"?  if(abc)->if (abc) 
[peng]thanks, I will send another patch to add this space in file va_trace.c 

-----Original Message-----
From: Libva [mailto:libva-bounces at lists.freedesktop.org] On Behalf Of peng.chen
Sent: Monday, May 23, 2016 1:46 PM
To: libva at lists.freedesktop.org
Subject: [Libva] [PATCH V1][libva] fix check NULL issues reported by Klockwork

Signed-off-by: peng.chen <peng.c.chen at intel.com>
---
 va/va_trace.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/va/va_trace.c b/va/va_trace.c index 994422e..398ca1a 100644
--- a/va/va_trace.c
+++ b/va/va_trace.c
@@ -501,7 +501,10 @@ static void FILE_NAME_SUFFIX(
     int tmp = strnlen(env_value, max_size);
     int left = max_size - tmp;
     struct timeval tv;
-    int size = strlen(suffix_str);
+    int size = 0;
+    
+    if(suffix_str)
+        strlen(suffix_str);
 
     if(left < (size + 8 + 10))
         return;
@@ -735,8 +738,14 @@ void va_TraceInit(VADisplay dpy)
     struct va_trace *pva_trace = calloc(sizeof(struct va_trace), 1);
     struct trace_context *trace_ctx = calloc(sizeof(struct trace_context), 1);
 
-    if (pva_trace == NULL || trace_ctx == NULL)
+    if (pva_trace == NULL || trace_ctx == NULL) {
+        if(pva_trace)
+            free(pva_trace);
+
+        if(trace_ctx)
+            free(trace_ctx);
         return;
+    }
 
     if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
         pva_trace->fn_log_env = strdup(env_value); @@ -1474,6 +1483,9 @@ void va_TraceCreateBuffer (
     VABufferID *buf_id		/* out */
 )
 {
+    if(!buf_id)
+        return;
+
     DPY2TRACECTX(dpy, context, VA_INVALID_ID);
 
     add_trace_buf_info(pva_trace, context, *buf_id);
--
1.9.1

_______________________________________________
Libva mailing list
Libva at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libva


More information about the Libva mailing list