https://bugs.llvm.org/show_bug.cgi?id=46314

            Bug ID: 46314
           Summary: Spurious warning "Use of memory after it is freed"
                    after realloc
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

The code

a (int x)
{
  char in, re;
  unsigned next;
  in = malloc (1);
  next = 0;
  if (x)
     next = 2;
  re = realloc (in, next);
  return re == ((void *) 0) ? in : re;
}


causes --analyze to emit

bad.c:10:3: warning: Use of memory after it is freed [unix.Malloc]
  return re == ((void *) 0) ? in : re;

which appears to be a false positive.

Tested with 
Ubuntu clang version
11.0.0-++20200612052611+b2a37cfe2bd-1~exp1~20200612153223.70 
but also affects 
clang version 11.0.0-++20200523063809+304b0ed4039-1~exp1~20200523164413.1701

Reduced from https://github.com/zlib-ng/zlib-ng/issues/593

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to