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

Yuan, Shengquan shengquan.yuan at intel.com
Mon May 23 05:51:59 UTC 2016


Can you also add a space after "if"?  if(abc)->if (abc) 

-----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