Skip to content
Snippets Groups Projects
Commit d2b525e7 authored by George Burgess IV's avatar George Burgess IV
Browse files

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
parent c0cd03e8
No related branches found
No related tags found
No related merge requests found
......@@ -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)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment