From 56ec8cb6dcbb0e7a844f2f3e37b646bb57a737db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Sun, 12 Nov 2017 21:01:31 +0100 Subject: Port https://github.com/dotnet/coreclr/pull/13148 to master (#14999) --- src/ilasm/typar.hpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/ilasm') diff --git a/src/ilasm/typar.hpp b/src/ilasm/typar.hpp index 143a4a2da3..146128e30a 100644 --- a/src/ilasm/typar.hpp +++ b/src/ilasm/typar.hpp @@ -51,17 +51,27 @@ private: class TyParList { public: - TyParList(DWORD a, BinStr* b, LPCUTF8 n, TyParList* nx = NULL) + TyParList(DWORD a, BinStr* b, LPCUTF8 n, TyParList* nx = NULL) { bound = (b == NULL) ? new BinStr() : b; bound->appendInt32(0); // zero terminator - attrs = a; name = n; next = nx; - }; - ~TyParList() - { - if(bound) delete bound; - if (next) delete next; - }; + attrs = a; name = n; next = nx; + }; + ~TyParList() + { + if( bound) delete bound; + + // To avoid excessive stack usage (especially in debug builds), we break the next chain + // and delete as we traverse the link list + TyParList *pCur = next; + while (pCur != NULL) + { + TyParList *pTmp = pCur->next; + pCur->next = NULL; + delete pCur; + pCur = pTmp; + } + }; int Count() { TyParList* tp = this; @@ -154,7 +164,7 @@ public: TyParList* Next() { return next; }; BinStr* Bound() { return bound; }; private: - BinStr* bound; + BinStr* bound; LPCUTF8 name; TyParList* next; DWORD attrs; -- cgit v1.2.3