![](https://secure.gravatar.com/avatar/5634a99cd64dd70d4a6692c3031a1284.jpg?s=120&d=mm&r=g)
Raymond Toy pushed to branch issue-306-lisp.c at cmucl / cmucl Commits: 74311063 by Raymond Toy at 2024-07-24T09:35:29-07:00 Handle leak of searched_core The initial fix of just returning NULL when `core` is NULL or when `core` is not accessible like so: ``` if (core && access(core, R_OK) != 0) { return NULL; } ``` fixed the analyzer warning that we were leaking `core`. I think the analyzer is wrong here. If `core` was set by `search_core` but it is inaccessible, we'd return NULL without freeing the space returned by search_core. Instead we do this so that we the searched core is NULL or if it's not accessible, we free the space before returning. This also fixes the analyzer warning. - - - - - 1 changed file: - src/lisp/lisp.c Changes: ===================================== src/lisp/lisp.c ===================================== @@ -442,16 +442,24 @@ fpu_mode_t fpu_mode = SSE2; static const char* locate_core(const char* cmucllib, const char* core, const char* default_core) { + char* searched_core = NULL; + if (core == NULL) { if (getenv("CMUCLCORE") == NULL) { - core = search_core(cmucllib, default_core); + searched_core = search_core(cmucllib, default_core); + core = searched_core; } else { core = getenv("CMUCLCORE"); } } - if (core && access(core, R_OK) != 0) { - return NULL; + if (core) { + if (access(core, R_OK) != 0) { + if (searched_core) { + free(searched_core); + } + return NULL; + } } return core; View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/743110632996741b9d8f0513... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/743110632996741b9d8f0513... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)