YaGL: Prevent potential null pointer dereference in yagl_egl_release_current_context() 06/245906/1
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Wed, 14 Oct 2020 12:05:15 +0000 (14:05 +0200)
committerSylwester Nawrocki <s.nawrocki@samsung.com>
Mon, 19 Oct 2020 12:41:11 +0000 (14:41 +0200)
This fixes a potential NULL pointer dereference issue as pointed out
by SVACE warning:

* DEREF_OF_NULL.ASSIGN: Pointer 'egl_api_ts', which is dereferenced
   at yagl_host_egl_calls.c:184, may have NULL value.
   [dereference] Dereference at hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c:184
   [null] Assign null at hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c:182

Change-Id: I5003403ebc881fb2ebc91d9e1be132ff4d87f2e3
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c

index 46f120f..a8fbb57 100644 (file)
@@ -179,7 +179,13 @@ static __inline bool yagl_validate_context(struct yagl_thread_state *cur_ts,
 
 static bool yagl_egl_release_current_context(struct yagl_thread_state *cur_ts, struct yagl_egl_display *dpy)
 {
-    struct yagl_egl_api_ts *egl_api_ts = (cur_ts ? cur_ts->egl_api_ts : NULL);
+    struct yagl_egl_api_ts *egl_api_ts;
+
+    if (!cur_ts) {
+        return false;
+    }
+
+    egl_api_ts = cur_ts->egl_api_ts;
 
     if (!egl_api_ts->context) {
         return true;