You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A pointer containing the dynamically loaded zlib library was not being properly cleaned up. This is picked up by our Coverity scans.
One solution to this would be to store the handle to the library alongside the function pointers to functoin within that library. Then, we can free the library whenever we call `inflateEnd` or `deflateEnd`. However, this solution ended up not being necessary.
Another solution (the one this commit implements) removes zlib from being dynamically loaded in the first place. This is possible since we already link zlib with the runtime during compilation, and so loading zlib dynamically is uncecessary.
This fixes the following Coverity issue:
```
lib/pkg_editor/src/zlib.c:119:1:
Type: Resource leak (RESOURCE_LEAK)
lib/pkg_editor/src/zlib.c:98:3:
1. path: Condition "zlib_interface.deflateInit_", taking false branch.
lib/pkg_editor/src/zlib.c:101:3:
2. alloc_fn: Storage is returned from allocation function "zlib_load_library".
lib/pkg_editor/src/zlib.c:90:3:
2.1. path: Condition "dlopen_handle", taking false branch.
lib/pkg_editor/src/zlib.c:93:3:
2.2. alloc_fn: Storage is returned from allocation function "dlopen".
lib/pkg_editor/src/zlib.c:93:3:
2.3. return_alloc_fn: Directly returning storage allocated by "dlopen".
lib/pkg_editor/src/zlib.c:101:3:
3. var_assign: Assigning: "library" = storage returned from "zlib_load_library()".
lib/pkg_editor/src/zlib.c:102:3:
4. path: Condition "library == NULL", taking false branch.
lib/pkg_editor/src/zlib.c:110:3:
5. noescape: Resource "library" is not freed or pointed-to in "load_one_symbol".
lib/pkg_editor/src/zlib.c:39:36:
5.1. noescape: "load_one_symbol(void *, char const *)" does not free or save its parameter "library".
lib/pkg_editor/src/zlib.c:111:3:
6. noescape: Resource "library" is not freed or pointed-to in "load_one_symbol".
lib/pkg_editor/src/zlib.c:39:36:
6.1. noescape: "load_one_symbol(void *, char const *)" does not free or save its parameter "library".
lib/pkg_editor/src/zlib.c:112:3:
7. noescape: Resource "library" is not freed or pointed-to in "load_one_symbol".
lib/pkg_editor/src/zlib.c:39:36:
7.1. noescape: "load_one_symbol(void *, char const *)" does not free or save its parameter "library".
lib/pkg_editor/src/zlib.c:113:3:
8. noescape: Resource "library" is not freed or pointed-to in "load_one_symbol".
lib/pkg_editor/src/zlib.c:39:36:
8.1. noescape: "load_one_symbol(void *, char const *)" does not free or save its parameter "library".
lib/pkg_editor/src/zlib.c:114:3:
9. noescape: Resource "library" is not freed or pointed-to in "load_one_symbol".
lib/pkg_editor/src/zlib.c:39:36:
9.1. noescape: "load_one_symbol(void *, char const *)" does not free or save its parameter "library".
lib/pkg_editor/src/zlib.c:115:3:
10. noescape: Resource "library" is not freed or pointed-to in "load_one_symbol".
lib/pkg_editor/src/zlib.c:39:36:
10.1. noescape: "load_one_symbol(void *, char const *)" does not free or save its parameter "library".
lib/pkg_editor/src/zlib.c:119:1:
11. leaked_storage: Variable "library" going out of scope leaks the storage it points to.
```
0 commit comments