[Libva] [PATCH V1][libva] fix check NULL issues

Sean V Kelley seanvk at posteo.de
Fri May 27 21:41:19 UTC 2016



On 05/26/2016 10:16 PM, peng.chen wrote:
> v2:
> code clean up
> 
> v1:
> initial
> 
> Signed-off-by: peng.chen <peng.c.chen at intel.com>

Thanks applied.

Sean

> ---
>  va/va_trace.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/va/va_trace.c b/va/va_trace.c
> index 994422e..8f43493 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,12 @@ 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) {
> +        free(pva_trace);
> +        free(trace_ctx);
> +
>          return;
> +    }
>  
>      if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) {
>          pva_trace->fn_log_env = strdup(env_value);
> @@ -1474,6 +1481,9 @@ void va_TraceCreateBuffer (
>      VABufferID *buf_id		/* out */
>  )
>  {
> +    if (!buf_id || *buf_id == VA_INVALID_ID)
> +        return;
> +
>      DPY2TRACECTX(dpy, context, VA_INVALID_ID);
>  
>      add_trace_buf_info(pva_trace, context, *buf_id);
> @@ -1503,7 +1513,10 @@ void va_TraceDestroyBuffer (
>      
>      VACodedBufferSegment *buf_list;
>      int i = 0;
> -    
> +
> +    if (buf_id == VA_INVALID_ID)
> +        return;
> +
>      DPY2TRACECTX(dpy, VA_INVALID_ID, buf_id);
>  
>      vaBufferInfo(dpy, trace_ctx->trace_context, buf_id, &type, &size, &num_elements);    
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/libva/attachments/20160527/57c3c89e/attachment.sig>


More information about the Libva mailing list