gcc/analyzer/ChangeLog:
PR analyzer/104062
* region-model-manager.cc
(region_model_manager::maybe_fold_sub_svalue): Avoid casting to
NULL type when folding access to repeated svalue.
gcc/testsuite/ChangeLog:
PR analyzer/104062
* gcc.dg/analyzer/pr104062.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
if (const repeated_svalue *repeated_sval
= parent_svalue->dyn_cast_repeated_svalue ())
- return get_or_create_cast (type, repeated_sval->get_inner_svalue ());
+ if (type)
+ return get_or_create_cast (type, repeated_sval->get_inner_svalue ());
return NULL;
}
--- /dev/null
+void *
+calloc (__SIZE_TYPE__, __SIZE_TYPE__);
+
+void *
+realloc (void *, __SIZE_TYPE__);
+
+void
+foo (void)
+{
+ int *ap5 = calloc (4, sizeof *ap5);
+ int *ap7 = realloc (ap5, sizeof *ap5);
+} /* { dg-warning "leak of 'ap5'" "leak of ap5" } */
+/* { dg-warning "leak of 'ap7'" "leak of ap7" { target *-*-* } .-1 } */