diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2011-02-05 01:09:40 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2011-02-05 01:09:40 +0000 |
commit | 4f616b5942604fc1bad90a7fff5d57bb206d7353 (patch) | |
tree | eee95371979bd05f8e10baac9fc1891f175aa109 /Source | |
parent | f4c74bc500195797d41fad5d1203a0c109ab00e7 (diff) | |
download | swig-4f616b5942604fc1bad90a7fff5d57bb206d7353.tar.gz |
SF #3127633 Fix infinite loop in recursive typedef resolution.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12433 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Swig/typesys.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index ec4376af4..a1445f200 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -107,7 +107,7 @@ static Typetab *global_scope = 0; /* The global scope static Hash *scopes = 0; /* Hash table containing fully qualified scopes */ /* Performance optimization */ -#define SWIG_TYPEDEF_RESOLVE_CACHE +#define SWIG_TYPEDEF_RESOLVE_CACHE static Hash *typedef_resolve_cache = 0; static Hash *typedef_all_cache = 0; static Hash *typedef_qualified_cache = 0; @@ -809,6 +809,7 @@ return_result: SwigType *SwigType_typedef_resolve_all(const SwigType *t) { SwigType *n; SwigType *r; + int count = 0; /* Check to see if the typedef resolve has been done before by checking the cache */ if (!typedef_all_cache) { @@ -824,6 +825,10 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) { while ((n = SwigType_typedef_resolve(r))) { Delete(r); r = n; + if (++count >= 512) { + Swig_error(Getfile(t), Getline(t), "Recursive typedef detected resolving '%s' to '%s' to '%s' and so on...\n", SwigType_str(t, 0), SwigType_str(SwigType_typedef_resolve(t), 0), SwigType_str(SwigType_typedef_resolve(SwigType_typedef_resolve(t)), 0)); + break; + } } /* Add the typedef to the cache for next time it is looked up */ |