From 635e3eccfb24c962ddc2c9e501689fc78d49e894 Mon Sep 17 00:00:00 2001 From: "Luis A. Lozano" <llozano@google.com> Date: Tue, 22 Aug 2017 18:20:26 -0700 Subject: [PATCH] Fix possible memory leak warning. Static analyzer complains the memory pointed by list in bcurrent is not deallocated before returning. But since this code is in "main" routine, we don't care about the deallocation. Just ignore the warning. Bug: b/27101951 Test: Verified warning is gone. Change-Id: I58d784b61a5ad30d1406bd7c6b28c5713abf2b34 --- tools/fc_sort/fc_sort.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/fc_sort/fc_sort.c b/tools/fc_sort/fc_sort.c index 9a3a3ee14..fcd62eb44 100644 --- a/tools/fc_sort/fc_sort.c +++ b/tools/fc_sort/fc_sort.c @@ -507,9 +507,17 @@ int main(int argc, char *argv[]) (file_context_bucket_t *) malloc(sizeof(file_context_bucket_t)); if (!(bcurrent->next)) { - printf - ("Error: failure allocating memory.\n"); - return -1; + // Static analyzer complains about a + // memory leak of the memory used by the + // list created with bcurrent. We could + // try to deallocate it before returning + // it but since this is the "main" + // routine, it is not worth doing + // that. Just silence the static analyzer. + // NOLINTNEXTLINE + printf + ("Error: failure allocating memory.\n"); + return -1; } /* Make sure the new bucket thinks it's the end of the -- GitLab