5
Last change
on this file since de9b7d7 was
de9b7d7,
checked in by Sebastian Huber <sebastian.huber@…>, on 06/01/18 at 05:04:45
|
Add RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE
An invalid heap usage such as a double free is usually a fatal error
since this indicates a use after free. Replace the use of printk() in
free() with a fatal error.
Update #3437.
|
-
Property mode set to
100644
|
File size:
829 bytes
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief calloc() |
---|
5 | * @ingroup libcsupport |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #ifdef RTEMS_NEWLIB |
---|
22 | #include "malloc_p.h" |
---|
23 | #include <stdlib.h> |
---|
24 | |
---|
25 | void free( |
---|
26 | void *ptr |
---|
27 | ) |
---|
28 | { |
---|
29 | if ( !ptr ) |
---|
30 | return; |
---|
31 | |
---|
32 | /* |
---|
33 | * Do not attempt to free memory if in a critical section or ISR. |
---|
34 | */ |
---|
35 | if ( _Malloc_System_state() != MALLOC_SYSTEM_STATE_NORMAL ) { |
---|
36 | _Malloc_Deferred_free(ptr); |
---|
37 | return; |
---|
38 | } |
---|
39 | |
---|
40 | if ( !_Protected_heap_Free( RTEMS_Malloc_Heap, ptr ) ) { |
---|
41 | rtems_fatal( RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE, (rtems_fatal_code) ptr ); |
---|
42 | } |
---|
43 | } |
---|
44 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.