Skip to content

Commit 203d795

Browse files
authored
Merge pull request #1772 from tannewt/fix_gc_never_free
Check that a never free pointer is on the heap.
2 parents de38ce7 + 44e3250 commit 203d795

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@
3636
// USB is always used internally so skip the pin objects for it.
3737
#define IGNORE_PIN_PA24 1
3838
#define IGNORE_PIN_PA25 1
39+
40+
// Not connected
41+
#define IGNORE_PIN_PA13 1
42+
#define IGNORE_PIN_PA28 1

ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CHIP_VARIANT = SAMD21G18A
1111
CHIP_FAMILY = samd21
1212

1313
# Make room for frozen libraries.
14-
CFLAGS_INLINE_LIMIT = 65
14+
CFLAGS_INLINE_LIMIT = 55
1515

1616
EXTERNAL_FLASH_DEVICE_COUNT = 1
1717
EXTERNAL_FLASH_DEVICES = "W25Q32FV"

py/gc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,10 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
945945
#endif // Alternative gc_realloc impl
946946

947947
bool gc_never_free(void *ptr) {
948+
// Check to make sure the pointer is on the heap in the first place.
949+
if (gc_nbytes(ptr) == 0) {
950+
return false;
951+
}
948952
// Pointers are stored in a linked list where each block is BYTES_PER_BLOCK long and the first
949953
// pointer is the next block of pointers.
950954
void ** current_reference_block = MP_STATE_MEM(permanent_pointers);

0 commit comments

Comments
 (0)