summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2018-07-25 12:29:11 +0200
committerBen Boeckel <mathstuf@gmail.com>2018-07-25 12:29:11 +0200
commitbe843d1c0da52ff1397dbec8b87dabe1299b796b (patch)
tree67d407ddf3bdaa0c025c694ed15fd0916e8147a1
parenta19bdae674880d7dc4b8d1302b42805c091e4fd0 (diff)
downloadnspr-hg-be843d1c0da52ff1397dbec8b87dabe1299b796b.tar.gz
Bug 557922, Memory leaks in NSPR, ErrorTables, r=kaie based on wtc's original review
-rw-r--r--pr/include/private/primpl.h1
-rw-r--r--pr/src/linking/prlink.c5
-rw-r--r--pr/src/misc/prerrortable.c20
-rw-r--r--pr/src/misc/prinit.c2
-rw-r--r--pr/src/pthreads/ptthread.c3
-rw-r--r--pr/src/threads/prtpd.c4
6 files changed, 33 insertions, 2 deletions
diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h
index a817c206..7da6e4a6 100644
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1802,6 +1802,7 @@ extern void _PR_InitDtoa(void);
extern void _PR_InitTime(void);
extern void _PR_InitMW(void);
extern void _PR_InitRWLocks(void);
+extern void _PR_CleanupErrorTables();
extern void _PR_CleanupThread(PRThread *thread);
extern void _PR_CleanupCallOnce(void);
extern void _PR_CleanupMW(void);
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c
index 47154608..0657121f 100644
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -216,8 +216,6 @@ void _PR_InitLinker(void)
*/
void _PR_ShutdownLinker(void)
{
- /* FIXME: pr_exe_loadmap should be destroyed. */
-
PR_DestroyMonitor(pr_linker_lock);
pr_linker_lock = NULL;
@@ -225,6 +223,9 @@ void _PR_ShutdownLinker(void)
free(_pr_currentLibPath);
_pr_currentLibPath = NULL;
}
+
+ free(pr_exe_loadmap->name);
+ PR_FREEIF(pr_exe_loadmap);
}
/******************************************************************************/
diff --git a/pr/src/misc/prerrortable.c b/pr/src/misc/prerrortable.c
index 285fde97..d2a17c1d 100644
--- a/pr/src/misc/prerrortable.c
+++ b/pr/src/misc/prerrortable.c
@@ -181,6 +181,26 @@ PR_ErrorInstallTable(const struct PRErrorTable *table)
return 0;
}
+void
+_PR_CleanupErrorTables()
+{
+ struct PRErrorTableList *et;
+
+ et = Table_List;
+
+ while (et) {
+ struct PRErrorTableList *next_et;
+
+ next_et = et->next;
+
+ PR_FREEIF(et);
+
+ et = next_et;
+ }
+
+ Table_List = NULL;
+}
+
PR_IMPLEMENT(void)
PR_ErrorInstallCallback(const char * const * languages,
PRErrorCallbackLookupFn *lookup,
diff --git a/pr/src/misc/prinit.c b/pr/src/misc/prinit.c
index 43048a0d..0b667927 100644
--- a/pr/src/misc/prinit.c
+++ b/pr/src/misc/prinit.c
@@ -379,6 +379,8 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
_PR_MD_EARLY_CLEANUP();
+ _PR_CleanupErrorTables();
+
_PR_CleanupMW();
_PR_CleanupTime();
_PR_CleanupDtoa();
diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c
index e61a4cbd..1f29afed 100644
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -1095,6 +1095,8 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup(void)
_PR_MD_EARLY_CLEANUP();
+ _PR_CleanupErrorTables();
+
_PR_CleanupMW();
_PR_CleanupTime();
_PR_CleanupDtoa();
@@ -1127,6 +1129,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup(void)
#ifdef _PR_ZONE_ALLOCATOR
_PR_DestroyZones();
#endif
+ _PR_CleanupTPD();
_pr_initialized = PR_FALSE;
return PR_SUCCESS;
}
diff --git a/pr/src/threads/prtpd.c b/pr/src/threads/prtpd.c
index 0eb2a011..14859ee3 100644
--- a/pr/src/threads/prtpd.c
+++ b/pr/src/threads/prtpd.c
@@ -72,6 +72,10 @@ void _PR_InitTPD(void)
*/
void _PR_CleanupTPD(void)
{
+ _pr_tpd_length = 0;
+ _pr_tpd_highwater = 0;
+ PR_FREEIF(_pr_tpd_destructors);
+ _pr_tpd_destructors = NULL;
} /* _PR_CleanupTPD */
/*