[Libva] [PATCH V1][libva] fix check NULL issues reported by Klockwork
Chen, Peng C
peng.c.chen at intel.com
Mon May 23 07:02:00 UTC 2016
-----Original Message-----
From: Zhao, Yakui
Sent: Monday, May 23, 2016 2:51 PM
To: Chen, Peng C <peng.c.chen at intel.com>
Cc: libva at lists.freedesktop.org
Subject: Re: [Libva] [PATCH V1][libva] fix check NULL issues reported by Klockwork
On 05/23/2016 01:46 PM, peng.chen wrote:
> 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;
Maybe the zero buf_id is the valid buffer id.
The check should be changed as the following:
if (buf_id == VA_INVALID_ID)
return
[Peng] here it means the pointer, not the value itself.
> +
> DPY2TRACECTX(dpy, context, VA_INVALID_ID);
>
> add_trace_buf_info(pva_trace, context, *buf_id);
More information about the Libva
mailing list