[LLVMbugs] [Bug 19585] New: Memory leak with realloc() not reported.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Apr 28 08:18:00 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19585
Bug ID: 19585
Summary: Memory leak with realloc() not reported.
Product: clang
Version: 3.4
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: llvm-bugs at skybert.org
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
#include <stdlib.h>
int
main (void)
{
void* memory = malloc (20);
memory = realloc (memory, 40);
if (memory)
free (memory);
return 0;
}
Possible outcome:
malloc() works and returns value.
realloc() fails and overwrites pointer to first allocation.
Since realloc() doesn't free pointer to original memory, the original malloc()
is leaked.
The analyzer correctly warns that memory might leak.
But if "if (memory)" is removed (resulting in an unconditional free()), the
warning disappears.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140428/59ba8dd5/attachment.html>
More information about the llvm-bugs
mailing list