diff options
author | peng.chen <peng.c.chen@intel.com> | 2016-05-27 13:16:20 +0800 |
---|---|---|
committer | Sean V Kelley <seanvk@posteo.de> | 2016-05-27 14:38:07 -0700 |
commit | 2d27be4fe667db77e9ca7ad17fb944908143bff6 (patch) | |
tree | c57c1804c9cdf8e3fca25d39fad06a3b8a5039d4 /va/va_trace.c | |
parent | 18c049a226de085c8690c6a925a57710ab8b107d (diff) |
fix check NULL issues
v2:
code clean up
v1:
initial
Signed-off-by: peng.chen <peng.c.chen@intel.com>
Diffstat (limited to 'va/va_trace.c')
-rw-r--r-- | va/va_trace.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/va/va_trace.c b/va/va_trace.c index f75b876..4e1b8e8 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); |