summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2018-10-31 18:08:21 -0700
committerGeorge Burgess IV <gbiv@google.com>2018-10-31 18:13:17 -0700
commitd2b525e7650e9f81dfaa14656866318c45d0b765 (patch)
tree17e8e5cbcfba3be5a82ce08deafac0984a3f9c4e
parentc0cd03e863533355420356bc0b6432541640e2a2 (diff)
downloaddevice_generic_opengl-transport-d2b525e7650e9f81dfaa14656866318c45d0b765.tar.gz
device_generic_opengl-transport-d2b525e7650e9f81dfaa14656866318c45d0b765.tar.bz2
device_generic_opengl-transport-d2b525e7650e9f81dfaa14656866318c45d0b765.zip
Silence a static analyzer warning
Our static analyzer is unhappy with this code, and thinks it has a memory leak: device/generic/opengl-transport/host/libs/virglrenderer/AVDVirglRenderer.cpp:343:38: warning: Potential leak of memory pointed to by 'config' [clang-analyzer-cplusplus.NewDeleteLeaks] While this immediately seems true, the constructor for `config` will stash a pointer to `config` in a static vector, which presumably is meant to manage the lifetime of our newly-allocated `config`. As noted in the comments, the analyzer can generally reason about that, but it gives up trying to figure out what the constructor is doing before we reach the vector's push_back. Just put a NOLINT here to make it be quiet. Bug: None Test: Ran the analyzer. It's no longer angry. Change-Id: Ida0118ef8b9ca0cd40cdd5e76489ab14cb86ea23
-rw-r--r--host/libs/virglrenderer/AVDVirglRenderer.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/host/libs/virglrenderer/AVDVirglRenderer.cpp b/host/libs/virglrenderer/AVDVirglRenderer.cpp
index 2be15d5a1..788c3eddd 100644
--- a/host/libs/virglrenderer/AVDVirglRenderer.cpp
+++ b/host/libs/virglrenderer/AVDVirglRenderer.cpp
@@ -340,6 +340,14 @@ int virgl_renderer_init(void* cookie, int flags, virgl_renderer_callbacks* cb) {
g_dpy = EGL_NO_DISPLAY;
return ENOENT;
}
+
+ // Our static analyzer sees the `new`ing of `config` below without any sort
+ // of attempt to free it, and warns about it. Normally, it would catch that
+ // we're pushing it into a vector in the constructor, but it hits an
+ // internal evaluation limit when trying to evaluate the loop inside of the
+ // ctor. So, it never gets to see that we escape our newly-allocated
+ // `config` instance. Silence the warning, since it's incorrect.
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
for (EGLint c = 0; c < nConfigs; c++) {
EGLint configId;
if (!s_egl.eglGetConfigAttrib(g_dpy, configs[c], EGL_CONFIG_ID, &configId)) {