Reset the sqlite3_data_directory and sqlite3_temp_directory variables when the sqlite3_shutdown function is called since they may refer to memory allocated by the heap subsystem that was just shutdown.
FossilOrigin-Name: cd70bc4b788b947d47a7a7158c27028160df06bd
diff --git a/src/main.c b/src/main.c
index 601138b..31e5fb8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -287,6 +287,15 @@
sqlite3GlobalConfig.isMutexInit = 0;
}
+ /* The heap subsystem has now been shutdown and these values are supposed
+ ** to be NULL or point to memory that was obtained from sqlite3_malloc(),
+ ** which would rely on that heap subsystem; therefore, make sure these
+ ** values cannot refer to heap memory that was just invalidated when the
+ ** heap subsystem was shutdown.
+ */
+ sqlite3_data_directory = 0;
+ sqlite3_temp_directory = 0;
+
return SQLITE_OK;
}