From: Todd C. Miller Date: Wed, 16 May 2018 16:14:39 +0000 (-0600) Subject: Add cppcheck annotation to suppress memory leak false positive. X-Git-Tag: SUDO_1_8_24^2~77 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b31656b7f1eb3b1ff0cb028216a4cb45d3b0db6b;p=sudo Add cppcheck annotation to suppress memory leak false positive. --- diff --git a/plugins/sudoers/pwutil.c b/plugins/sudoers/pwutil.c index e170c31e5..405d20eb6 100644 --- a/plugins/sudoers/pwutil.c +++ b/plugins/sudoers/pwutil.c @@ -213,6 +213,7 @@ sudo_getpwuid(uid_t uid) if (errno != ENOENT || (item = calloc(1, sizeof(*item))) == NULL) { sudo_warnx(U_("unable to cache uid %u, out of memory"), (unsigned int) uid); + /* cppcheck-suppress memleak */ debug_return_ptr(NULL); } item->refcnt = 1; @@ -284,6 +285,7 @@ sudo_getpwnam(const char *name) const size_t len = strlen(name) + 1; if (errno != ENOENT || (item = calloc(1, sizeof(*item) + len)) == NULL) { sudo_warnx(U_("unable to cache user %s, out of memory"), name); + /* cppcheck-suppress memleak */ debug_return_ptr(NULL); } item->refcnt = 1; @@ -528,6 +530,7 @@ sudo_getgrgid(gid_t gid) if (errno != ENOENT || (item = calloc(1, sizeof(*item))) == NULL) { sudo_warnx(U_("unable to cache gid %u, out of memory"), (unsigned int) gid); + /* cppcheck-suppress memleak */ debug_return_ptr(NULL); } item->refcnt = 1; @@ -593,6 +596,7 @@ sudo_getgrnam(const char *name) const size_t len = strlen(name) + 1; if (errno != ENOENT || (item = calloc(1, sizeof(*item) + len)) == NULL) { sudo_warnx(U_("unable to cache group %s, out of memory"), name); + /* cppcheck-suppress memleak */ debug_return_ptr(NULL); } item->refcnt = 1;