-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
Description
I'm running version 14.0.0 obtained from https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
Consider this C program:
#include <stdlib.h>
#include <string.h>
struct mystruct {
void *ptr;
char arr[4];
};
int main(void) {
struct mystruct x;
x.ptr = malloc(1);
strcpy(x.arr, "hi\n");
free(x.ptr);
}
When I run clang --analyze /tmp/bug.c
, I get this:
/tmp/bug.c:13:5: warning: Potential leak of memory pointed to by 'x.ptr' [unix.Malloc]
free(x.ptr);
^~~~~~~~~~~
1 warning generated.
But it's clear that there's not actually a potential leak of memory here.