Summary: Adding a model for malloc: we add an attribute "Allocated". This can be used for implementing memory leaks: whenever the variables get out of scope, we can check that if the variable has an attribute Allocated, it also has an attribute Invalid CFree. Possibly we will need more details in the Allocated attribute, to know if it's malloc, or other allocation function, but we can add that later when we know how it should look like. Reviewed By: jvillard Differential Revision: D20364541 fbshipit-source-id: 5e667a8c3master
parent
82fb4e67b9
commit
2f90b05c2a
@ -0,0 +1,15 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
TESTS_DIR = ../../..
|
||||
|
||||
CLANG_OPTIONS = -c
|
||||
INFER_OPTIONS = --pulse-only --debug-exceptions --project-root $(TESTS_DIR)
|
||||
|
||||
INFERPRINT_OPTIONS = --issues-tests
|
||||
|
||||
SOURCES = $(wildcard *.c)
|
||||
|
||||
include $(TESTS_DIR)/clang.make
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
void malloc_no_free_bad() { // TODO implement the check
|
||||
int* p = malloc(sizeof(p));
|
||||
}
|
||||
|
||||
int* malloc_returned_ok() {
|
||||
int* p = malloc(sizeof(p));
|
||||
return p;
|
||||
}
|
||||
|
||||
void malloc_then_free_ok() {
|
||||
int* p = malloc(sizeof(p));
|
||||
*p = 5;
|
||||
free(p);
|
||||
}
|
Loading…
Reference in new issue