Set the terminal tilegrid NULL after free

Without this, a double free can occur when a display (and terminal)
is released and then a crash occurs. Upon a second release,
different memory is released (sometimes the heap). When this is
followed by an allocation for the flash cache, the cache can
overwrite the active heap causing crashes.

Fixes #1667
This commit is contained in:
Scott Shawcroft 2019-04-03 15:24:15 -07:00
parent 9bfa625170
commit a5520f8a3d
No known key found for this signature in database
GPG Key ID: FD0EDC4B6C53CA59

View File

@ -81,6 +81,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
void supervisor_stop_terminal(void) {
if (tilegrid_tiles != NULL) {
free_memory(tilegrid_tiles);
tilegrid_tiles = NULL;
supervisor_terminal_text_grid.inline_tiles = false;
supervisor_terminal_text_grid.tiles = NULL;
}